Douglas Gregor | 825faf7 | 2011-06-29 21:22:02 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Fariborz Jahanian | 4f9c9d6 | 2010-06-24 18:50:41 +0000 | [diff] [blame] | 2 | |
| 3 | // rdar: // 8125274 |
| 4 | static int a16[]; // expected-warning {{tentative array definition assumed to have one element}} |
| 5 | |
| 6 | void f16(void) { |
| 7 | extern int a16[]; |
| 8 | } |
| 9 | |
Douglas Gregor | 825faf7 | 2011-06-29 21:22:02 +0000 | [diff] [blame] | 10 | |
| 11 | // PR10013: Scope of extern declarations extend past enclosing block |
| 12 | extern int PR10013_x; |
| 13 | int PR10013(void) { |
| 14 | int *PR10013_x = 0; |
| 15 | { |
| 16 | extern int PR10013_x; |
| 17 | extern int PR10013_x; |
| 18 | } |
| 19 | |
| 20 | return PR10013_x; // expected-warning{{incompatible pointer to integer conversion}} |
| 21 | } |
| 22 | |
Rafael Espindola | 7581f32 | 2012-12-17 22:23:47 +0000 | [diff] [blame] | 23 | static int test1_a[]; // expected-warning {{tentative array definition assumed to have one element}} |
| 24 | extern int test1_a[]; |
John McCall | b65e8fe | 2013-04-01 18:34:28 +0000 | [diff] [blame] | 25 | |
| 26 | // rdar://13535367 |
| 27 | void test2declarer() { extern int test2_array[100]; } |
| 28 | extern int test2_array[]; |
| 29 | int test2v = sizeof(test2_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} |
| 30 | |
| 31 | void test3declarer() { |
| 32 | { extern int test3_array[100]; } |
| 33 | extern int test3_array[]; |
| 34 | int x = sizeof(test3_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} |
| 35 | } |
John McCall | a4da323 | 2013-04-13 00:20:21 +0000 | [diff] [blame^] | 36 | |
| 37 | void test4() { |
| 38 | extern int test4_array[]; |
| 39 | { |
| 40 | extern int test4_array[100]; |
| 41 | int x = sizeof(test4_array); // fine |
| 42 | } |
| 43 | int x = sizeof(test4_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} |
| 44 | } |