annotate gcc/testsuite/gcc.dg/gnu99-static-1.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* It is a constraint violation for a static function to be declared
kono
parents:
diff changeset
2 but not defined if it is used except in a sizeof expression whose
kono
parents:
diff changeset
3 result is an integer constant. In GNU C, we need to consider
kono
parents:
diff changeset
4 __typeof__ and __alignof__ as well. __alignof__ always returns a
kono
parents:
diff changeset
5 constant, so static functions can always be used therein.
kono
parents:
diff changeset
6 __typeof__ evaluates its argument iff it has variably modified
kono
parents:
diff changeset
7 type. */
kono
parents:
diff changeset
8 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
kono
parents:
diff changeset
9 /* { dg-do compile } */
kono
parents:
diff changeset
10 /* { dg-options "-O2 -std=gnu99 -pedantic-errors" } */
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 /* __alignof__, OK. */
kono
parents:
diff changeset
13 static int f0(void);
kono
parents:
diff changeset
14 void g0(void) { __alignof__(f0()); }
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 /* __typeof__ not variably modified, OK. */
kono
parents:
diff changeset
17 static int f1(void);
kono
parents:
diff changeset
18 void g1(void) { __typeof__(f1()) x; }
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 /* __typeof__ variably modified, not OK. */
kono
parents:
diff changeset
21 static int f2(void); /* { dg-error "used but never defined" } */
kono
parents:
diff changeset
22 void g2(void) { __typeof__(int [f2()]) x; }
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 /* __typeof__ variably modified, not OK. */
kono
parents:
diff changeset
25 static int f3(void); /* { dg-error "used but never defined" } */
kono
parents:
diff changeset
26 void g3(void) { __typeof__(int (*)[f3()]) x; }
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 /* Integer sizeof of VM typeof, OK. */
kono
parents:
diff changeset
29 static int f4(void);
kono
parents:
diff changeset
30 void g4(void) { sizeof(__typeof__(int (*)[f3()])); }