111
|
1 // { dg-do assemble }
|
|
2
|
|
3 // Copyright (C) 1999 Free Software Foundation, Inc.
|
|
4 // Contributed by Nathan Sidwell 5 Sep 1999 <nathan@acm.org>
|
|
5
|
|
6 // C++ does not decay lvalues into rvalues until as late as possible. This
|
|
7 // means things like the rhs of a comma operator mustn't decay. This will make
|
|
8 // a difference if it is an array or function.
|
|
9
|
|
10 struct S;
|
|
11 struct T {int m;};
|
|
12 extern S s; // an incomplete
|
|
13 extern S arys[20]; // an incomplete array
|
|
14 extern T aryt[]; // an incomplete array;
|
|
15
|
|
16 void fn () {}
|
|
17
|
|
18 int main (int argc, char **argv)
|
|
19 {
|
145
|
20 sizeof (s); // { dg-error "3:invalid application of .sizeof. to incomplete type" } incomplete
|
|
21 sizeof (0, s); // { dg-error "3:invalid application of .sizeof. to incomplete type" } incomplete
|
|
22 sizeof (argc ? s : s); // { dg-error "3:invalid application of .sizeof. to incomplete type" } incomplete
|
111
|
23
|
145
|
24 sizeof (arys); // { dg-error "3:invalid application of .sizeof. to incomplete type" } incomplete
|
|
25 sizeof (0, arys); // { dg-error "3:invalid application of .sizeof. to incomplete type" } incomplete
|
|
26 sizeof (argc ? arys : arys); // { dg-error "3:invalid application of .sizeof. to incomplete type" } incomplete
|
111
|
27
|
145
|
28 sizeof (aryt); // { dg-error "3:invalid application of .sizeof. to incomplete type" } incomplete
|
|
29 sizeof (0, aryt); // { dg-error "3:invalid application of .sizeof. to incomplete type" } incomplete
|
|
30 sizeof (argc ? aryt : aryt); // { dg-error "3:invalid application of .sizeof. to incomplete type" } incomplete
|
111
|
31
|
145
|
32 sizeof (fn); // { dg-error "11:ISO C\\+\\+ forbids applying .sizeof." } cannot take size of function
|
|
33 sizeof (0, fn); // { dg-error "3:invalid application of .sizeof. to a function type" } cannot take size of function
|
|
34 sizeof (argc ? fn : fn); // { dg-error "3:invalid application of .sizeof. to a function type" } cannot take size of function
|
111
|
35
|
|
36 sizeof (&fn); // ok
|
|
37 sizeof (0, &fn); // ok
|
|
38 sizeof (argc ? &fn : &fn); // ok
|
|
39
|
|
40 return 0;
|
|
41 }
|