annotate gcc/testsuite/gcc.dg/declspec-10.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test declaration specifiers. Test various checks on storage class
kono
parents:
diff changeset
2 and function specifiers that depend on information about the
kono
parents:
diff changeset
3 declaration, not just the specifiers. Test with -pedantic. */
kono
parents:
diff changeset
4 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
kono
parents:
diff changeset
5 /* { dg-do compile } */
kono
parents:
diff changeset
6 /* { dg-options "-pedantic" } */
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 auto void f0 (void) {} /* { dg-warning "function definition declared 'auto'" } */
kono
parents:
diff changeset
9 register void f1 (void) {} /* { dg-error "function definition declared 'register'" } */
kono
parents:
diff changeset
10 typedef void f2 (void) {} /* { dg-error "function definition declared 'typedef'" } */
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 void f3 (auto int); /* { dg-error "storage class specified for unnamed parameter" } */
kono
parents:
diff changeset
13 void f4 (extern int); /* { dg-error "storage class specified for unnamed parameter" } */
kono
parents:
diff changeset
14 void f5 (register int);
kono
parents:
diff changeset
15 void f6 (static int); /* { dg-error "storage class specified for unnamed parameter" } */
kono
parents:
diff changeset
16 void f7 (typedef int); /* { dg-error "storage class specified for unnamed parameter" } */
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 register int y;
kono
parents:
diff changeset
21 /* { dg-warning "file-scope declaration of 'y' specifies 'register'" "" { target *-*-* } .-1 } */
kono
parents:
diff changeset
22 /* { dg-message "error: register name not specified for 'y'" "not specified" { target *-*-* } .-2 } */
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 void h (void) { extern void x (void) {} } /* { dg-error "nested function 'x' declared 'extern'" } */
kono
parents:
diff changeset
25 /* { dg-warning "ISO C forbids nested functions" "nested" { target *-*-* } .-1 } */
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 void
kono
parents:
diff changeset
28 g (void)
kono
parents:
diff changeset
29 {
kono
parents:
diff changeset
30 void a; /* { dg-error "variable or field 'a' declared void" } */
kono
parents:
diff changeset
31 const void b; /* { dg-error "variable or field 'b' declared void" } */
kono
parents:
diff changeset
32 static void c; /* { dg-error "variable or field 'c' declared void" } */
kono
parents:
diff changeset
33 }
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 void p;
kono
parents:
diff changeset
36 const void p1;
kono
parents:
diff changeset
37 extern void q;
kono
parents:
diff changeset
38 extern const void q1;
kono
parents:
diff changeset
39 static void r; /* { dg-error "variable or field 'r' declared void" } */
kono
parents:
diff changeset
40 static const void r1; /* { dg-error "variable or field 'r1' declared void" } */
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 register void f8 (void); /* { dg-error "invalid storage class for function 'f8'" } */
kono
parents:
diff changeset
43 /* { dg-warning "file-scope declaration of 'f8' specifies 'register'" "register function" { target *-*-* } .-1 } */
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 void i (void) { auto void y (void) {} } /* { dg-warning "ISO C forbids nested functions" } */
kono
parents:
diff changeset
46 /* { dg-warning "function definition declared 'auto'" "nested" { target *-*-* } .-1 } */
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 inline int main (void) { return 0; } /* { dg-warning "cannot inline function 'main'" } */