1 |
327 |
jeremybenn |
/* Copyright (C) 2009 Free Software Foundation, Inc.
|
2 |
|
|
|
3 |
|
|
This file is free software; you can redistribute it and/or modify it under
|
4 |
|
|
the terms of the GNU General Public License as published by the Free
|
5 |
|
|
Software Foundation; either version 3 of the License, or (at your option)
|
6 |
|
|
any later version.
|
7 |
|
|
|
8 |
|
|
This file is distributed in the hope that it will be useful, but WITHOUT
|
9 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
11 |
|
|
for more details.
|
12 |
|
|
|
13 |
|
|
You should have received a copy of the GNU General Public License
|
14 |
|
|
along with this file; see the file COPYING3. If not see
|
15 |
|
|
<http://www.gnu.org/licenses/>. */
|
16 |
|
|
|
17 |
|
|
/* This is the same as ops2.c except for the compile option.
|
18 |
|
|
If you modify this code, please modify ops2.c as well. */
|
19 |
|
|
|
20 |
|
|
/* { dg-do compile } */
|
21 |
|
|
/* { dg-options "-O2 -std=gnu99 -pedantic-errors -maddress-space-conversion" } */
|
22 |
|
|
|
23 |
|
|
#define __lm
|
24 |
|
|
|
25 |
|
|
__ea int ea_var = 1;
|
26 |
|
|
__lm int lm_var = 2;
|
27 |
|
|
|
28 |
|
|
typedef __ea int *ea_ptr_t;
|
29 |
|
|
typedef __lm int *lm_ptr_t;
|
30 |
|
|
|
31 |
|
|
typedef __ea void *ea_vptr_t;
|
32 |
|
|
typedef __lm void *lm_vptr_t;
|
33 |
|
|
|
34 |
|
|
ea_ptr_t ea, ea2;
|
35 |
|
|
lm_ptr_t lm, lm2;
|
36 |
|
|
|
37 |
|
|
ea_vptr_t eav;
|
38 |
|
|
lm_vptr_t lmv;
|
39 |
|
|
|
40 |
|
|
extern void call_ea (ea_ptr_t);
|
41 |
|
|
extern void call_lm (lm_ptr_t);
|
42 |
|
|
|
43 |
|
|
/* Assignment, initialization, argument passing, and return. */
|
44 |
|
|
void to_ea (void) { ea = lm; }
|
45 |
|
|
void to_lm (void) { lm = ea; } /* { dg-error "assignment from pointer to non-enclosed address space" } */
|
46 |
|
|
void init_ea (void) { ea_ptr_t l_ea = lm; }
|
47 |
|
|
void init_lm (void) { lm_ptr_t l_lm = ea; } /* { dg-error "initialization from pointer to non-enclosed address space" } */
|
48 |
|
|
ea_ptr_t ret_ea (void) { return lm; }
|
49 |
|
|
lm_ptr_t ret_lm (void) { return ea; } /* { dg-error "return from pointer to non-enclosed address space" } */
|
50 |
|
|
void call_ea2 (void) { call_ea (lm); }
|
51 |
|
|
void call_lm2 (void) { call_lm (ea); } /* { dg-error "passing argument 1 of 'call_lm' from pointer to non-enclosed address space" } */
|
52 |
|
|
|
53 |
|
|
/* Explicit casts. */
|
54 |
|
|
void to_ea_with_cast (void) { ea = (ea_ptr_t)lm; }
|
55 |
|
|
void to_lm_with_cast (void) { lm = (lm_ptr_t)ea; }
|
56 |
|
|
void init_ea_with_cast (void) { ea_ptr_t l_ea = (ea_ptr_t)lm; }
|
57 |
|
|
void init_lm_with_cast (void) { lm_ptr_t l_lm = (lm_ptr_t)ea; }
|
58 |
|
|
ea_ptr_t ret_ea_with_cast (void) { return (ea_ptr_t)lm; }
|
59 |
|
|
lm_ptr_t ret_lm_with_cast (void) { return (lm_ptr_t)ea; }
|
60 |
|
|
void call_ea2_with_cast (void) { call_ea ((ea_ptr_t)lm); }
|
61 |
|
|
void call_lm2_with_cast (void) { call_lm ((lm_ptr_t)ea); }
|
62 |
|
|
|
63 |
|
|
/* Arithmetic operators. */
|
64 |
|
|
int sub_eaea (void) { return ea - ea2; }
|
65 |
|
|
int sub_ealm (void) { return ea - lm2; }
|
66 |
|
|
int sub_lmea (void) { return lm - ea2; }
|
67 |
|
|
int sub_lmlm (void) { return lm - lm2; }
|
68 |
|
|
ea_ptr_t if_eaea1 (int test) { return test? ea : ea2; }
|
69 |
|
|
lm_ptr_t if_eaea2 (int test) { return test? ea : ea2; } /* { dg-error "return from pointer to non-enclosed address space" } */
|
70 |
|
|
ea_ptr_t if_ealm1 (int test) { return test? ea : lm2; }
|
71 |
|
|
lm_ptr_t if_ealm2 (int test) { return test? ea : lm2; } /* { dg-error "return from pointer to non-enclosed address space" } */
|
72 |
|
|
ea_ptr_t if_lmea1 (int test) { return test? lm : ea2; }
|
73 |
|
|
lm_ptr_t if_lmea2 (int test) { return test? lm : ea2; } /* { dg-error "return from pointer to non-enclosed address space" } */
|
74 |
|
|
ea_ptr_t if_lmlm1 (int test) { return test? lm : lm2; }
|
75 |
|
|
lm_ptr_t if_lmlm2 (int test) { return test? lm : lm2; }
|
76 |
|
|
|
77 |
|
|
/* Relational operators. */
|
78 |
|
|
int eq_eaea (void) { return ea == ea2; }
|
79 |
|
|
int eq_ealm (void) { return ea == lm2; }
|
80 |
|
|
int eq_lmea (void) { return lm == ea2; }
|
81 |
|
|
int eq_lmlm (void) { return lm == lm2; }
|
82 |
|
|
int lt_eaea (void) { return ea < ea2; }
|
83 |
|
|
int lt_ealm (void) { return ea < lm2; }
|
84 |
|
|
int lt_lmea (void) { return lm < ea2; }
|
85 |
|
|
int lt_lmlm (void) { return lm < lm2; }
|
86 |
|
|
|
87 |
|
|
/* Null pointer. */
|
88 |
|
|
void null_ea1 (void) { ea = 0; }
|
89 |
|
|
void null_ea2 (void) { ea = (void *)0; }
|
90 |
|
|
void null_ea3 (void) { ea = (__ea void *)0; }
|
91 |
|
|
void null_lm1 (void) { lm = 0; }
|
92 |
|
|
void null_lm2 (void) { lm = (void *)0; }
|
93 |
|
|
void null_lm3 (void) { lm = (__ea void *)0; } /* { dg-error "assignment from pointer to non-enclosed address space" } */
|
94 |
|
|
|