annotate gcc/testsuite/g++.old-deja/g++.other/sizeof4.C @ 145:1830386684a0

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