Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Eli Friedman | 8df7462 | 2009-06-05 00:50:43 +0000 | [diff] [blame] | 2 | |
| 3 | // Note that this puts the expected lines before the directives to work around |
| 4 | // limitations in the -verify mode. |
| 5 | |
| 6 | int x; |
| 7 | /* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak |
| 8 | #pragma weak x |
Eli Friedman | 8df7462 | 2009-06-05 00:50:43 +0000 | [diff] [blame] | 9 | |
Eli Friedman | 3c1291d | 2009-06-05 02:49:06 +0000 | [diff] [blame] | 10 | extern int z; |
Eli Friedman | 8df7462 | 2009-06-05 00:50:43 +0000 | [diff] [blame] | 11 | /* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak z = = |
| 12 | /* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak z = |
Ryan Flynn | 7d470f3 | 2009-07-30 03:15:39 +0000 | [diff] [blame] | 13 | /* expected-warning {{weak identifier 'y' never declared}} */ #pragma weak z = y |
Eli Friedman | 8df7462 | 2009-06-05 00:50:43 +0000 | [diff] [blame] | 14 | |
Eli Friedman | 3c1291d | 2009-06-05 02:49:06 +0000 | [diff] [blame] | 15 | extern int a; |
Eli Friedman | 8df7462 | 2009-06-05 00:50:43 +0000 | [diff] [blame] | 16 | /* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a b |
| 17 | /* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a = x c |
Richard Smith | 426a47b | 2013-10-28 22:04:30 +0000 | [diff] [blame] | 18 | |
| 19 | |
| 20 | void pragma_is_not_a_statement(int x) |
| 21 | { |
| 22 | int t; |
| 23 | |
| 24 | { |
| 25 | if (x) |
| 26 | #pragma weak t |
| 27 | else // expected-error {{expected expression}} |
| 28 | #pragma weak t |
| 29 | } |
| 30 | |
| 31 | switch (x) { |
| 32 | case 1: |
| 33 | #pragma weak t |
| 34 | } // expected-error {{expected statement}} |
| 35 | switch(x) { |
| 36 | default: |
| 37 | #pragma weak t |
| 38 | } // expected-error {{expected statement}} |
| 39 | |
| 40 | label: |
| 41 | #pragma weak t |
| 42 | } // expected-error {{expected statement}} |
| 43 | |
| 44 | |