xref: /minix3/external/bsd/llvm/dist/clang/test/Parser/pragma-weak.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // Note that this puts the expected lines before the directives to work around
4*f4a2713aSLionel Sambuc // limitations in the -verify mode.
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc int x;
7*f4a2713aSLionel Sambuc /* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak
8*f4a2713aSLionel Sambuc #pragma weak x
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc extern int z;
11*f4a2713aSLionel Sambuc /* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak z = =
12*f4a2713aSLionel Sambuc /* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak z =
13*f4a2713aSLionel Sambuc /* expected-warning {{weak identifier 'y' never declared}} */ #pragma weak z = y
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc extern int a;
16*f4a2713aSLionel Sambuc /* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a b
17*f4a2713aSLionel Sambuc /* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a = x c
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc 
pragma_is_not_a_statement(int x)20*f4a2713aSLionel Sambuc void pragma_is_not_a_statement(int x)
21*f4a2713aSLionel Sambuc {
22*f4a2713aSLionel Sambuc   int t;
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc   {
25*f4a2713aSLionel Sambuc     if (x)
26*f4a2713aSLionel Sambuc #pragma weak t
27*f4a2713aSLionel Sambuc     else // expected-error {{expected expression}}
28*f4a2713aSLionel Sambuc #pragma weak t
29*f4a2713aSLionel Sambuc   }
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc   switch (x) {
32*f4a2713aSLionel Sambuc     case 1:
33*f4a2713aSLionel Sambuc #pragma weak t
34*f4a2713aSLionel Sambuc   } // expected-error {{expected statement}}
35*f4a2713aSLionel Sambuc   switch(x) {
36*f4a2713aSLionel Sambuc     default:
37*f4a2713aSLionel Sambuc #pragma weak t
38*f4a2713aSLionel Sambuc   } // expected-error {{expected statement}}
39*f4a2713aSLionel Sambuc 
40*f4a2713aSLionel Sambuc label:
41*f4a2713aSLionel Sambuc #pragma weak t
42*f4a2713aSLionel Sambuc } // expected-error {{expected statement}}
43*f4a2713aSLionel Sambuc 
44*f4a2713aSLionel Sambuc 
45