ADTast-experimentalpthread-emulation
Last change
on this file since a0dbf20 was
53692b3,
checked in by Peter A. Buhr <pabuhr@…>, 3 years ago
|
second attempt to fix compile-only pragma message that gcc-10/11 quote
|
-
Property mode set to
100644
|
File size:
2.5 KB
|
Line | |
---|
1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2020 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // init1.cfa -- tests of initializing pointer- and reference-typed variables and returns |
---|
8 | // |
---|
9 | // Author : Michael Brooks |
---|
10 | // Created On : Thu Jul 16 22:00:00 2020 |
---|
11 | // Last Modified By : Peter A. Buhr |
---|
12 | // Last Modified On : Sat Jun 5 10:06:57 2021 |
---|
13 | // Update Count : 9 |
---|
14 | // |
---|
15 | |
---|
16 | void f() { |
---|
17 | |
---|
18 | // |
---|
19 | // setup |
---|
20 | // |
---|
21 | |
---|
22 | float x = 3.14; |
---|
23 | |
---|
24 | float & rx = x; |
---|
25 | float * px = &x; |
---|
26 | |
---|
27 | const float & crx = x; |
---|
28 | const float * cpx = &x; |
---|
29 | |
---|
30 | // |
---|
31 | // sound initializations |
---|
32 | // |
---|
33 | |
---|
34 | char * str1 = "hi"; |
---|
35 | const char * str2 = "hi"; |
---|
36 | |
---|
37 | float & rx2 = rx; |
---|
38 | float * px2 = px; |
---|
39 | |
---|
40 | const float & crx2 = crx; |
---|
41 | const float * cpx2 = cpx; |
---|
42 | |
---|
43 | // FIX ME: Code gen not producing correct cast. |
---|
44 | #pragma GCC diagnostic push |
---|
45 | #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" |
---|
46 | int (* fp)( int ) = 0p; |
---|
47 | fp = 0p; |
---|
48 | #pragma GCC diagnostic pop |
---|
49 | |
---|
50 | // |
---|
51 | // unsound initializations |
---|
52 | // |
---|
53 | |
---|
54 | #ifdef ERR1 |
---|
55 | // mismatched referenced type |
---|
56 | int & ry = rx; |
---|
57 | int * py = px; |
---|
58 | |
---|
59 | // would discard refered constness (same float is referenced) |
---|
60 | float & ry2 = crx; |
---|
61 | float * py2 = cpx; |
---|
62 | #endif // ERR1 |
---|
63 | } |
---|
64 | |
---|
65 | // |
---|
66 | // sound returns |
---|
67 | // |
---|
68 | |
---|
69 | char * f_str1() { |
---|
70 | return "hi"; |
---|
71 | } |
---|
72 | |
---|
73 | const char * f_str2() { |
---|
74 | return "hi"; |
---|
75 | } |
---|
76 | |
---|
77 | float & f_rx2 () { |
---|
78 | float & rx = *0p; |
---|
79 | return rx; |
---|
80 | } |
---|
81 | |
---|
82 | float * f_px2 () { |
---|
83 | float * px = 0p; |
---|
84 | return px; |
---|
85 | } |
---|
86 | |
---|
87 | const float & f_crx2 () { |
---|
88 | float & rx = *0p; |
---|
89 | return rx; |
---|
90 | } |
---|
91 | |
---|
92 | const float * f_cpx2 () { |
---|
93 | float * px = 0p; |
---|
94 | return px; |
---|
95 | } |
---|
96 | |
---|
97 | // |
---|
98 | // unsound returns |
---|
99 | // |
---|
100 | |
---|
101 | #ifdef ERR1 |
---|
102 | int & f_ry() { |
---|
103 | float & rx = *0p; |
---|
104 | return rx; // mismatched referenced type |
---|
105 | } |
---|
106 | |
---|
107 | int * f_py() { |
---|
108 | float * px = 0p; |
---|
109 | return px; // mismatched referenced type |
---|
110 | } |
---|
111 | |
---|
112 | float & f_ry2() { |
---|
113 | const float & crx = *0p; |
---|
114 | return crx; // would discard refered constness (same float is referenced) |
---|
115 | } |
---|
116 | |
---|
117 | float * f_py2() { |
---|
118 | const float * cpx = 0p; |
---|
119 | return cpx; // would discard refered constness (same float is referenced) |
---|
120 | } |
---|
121 | |
---|
122 | forall (T &, S &) |
---|
123 | T & anycvt( S & s ) { |
---|
124 | return s; // mismatched referenced type |
---|
125 | } |
---|
126 | |
---|
127 | forall (T &, S &) |
---|
128 | T * anycvt( S * s ) { |
---|
129 | return s; // mismatched referenced type |
---|
130 | } |
---|
131 | #endif // ERR1 |
---|
132 | |
---|
133 | int main() { |
---|
134 | #pragma GCC warning "Compiled" // force non-empty .expect file, NO TABS!!! |
---|
135 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.