Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 8f30105 | 2009-02-24 19:23:27 +0000 | [diff] [blame] | 2 | |
| 3 | int outer1; // expected-note{{previous definition is here}} |
| 4 | extern int outer2; // expected-note{{previous definition is here}} |
| 5 | int outer4; |
| 6 | int outer4; // expected-note{{previous definition is here}} |
| 7 | int outer5; |
| 8 | int outer6(float); // expected-note{{previous definition is here}} |
| 9 | int outer7(float); |
| 10 | |
| 11 | void outer_test() { |
| 12 | extern float outer1; // expected-error{{redefinition of 'outer1' with a different type}} |
| 13 | extern float outer2; // expected-error{{redefinition of 'outer2' with a different type}} |
| 14 | extern float outer3; // expected-note{{previous definition is here}} |
| 15 | double outer4; |
| 16 | extern int outer5; // expected-note{{previous definition is here}} |
| 17 | extern int outer6; // expected-error{{redefinition of 'outer6' as different kind of symbol}} |
| 18 | int outer7; |
| 19 | extern int outer8; // expected-note{{previous definition is here}} |
| 20 | extern int outer9; |
| 21 | { |
| 22 | extern int outer9; // expected-note{{previous definition is here}} |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | int outer3; // expected-error{{redefinition of 'outer3' with a different type}} |
| 27 | float outer4; // expected-error{{redefinition of 'outer4' with a different type}} |
| 28 | float outer5; // expected-error{{redefinition of 'outer5' with a different type}} |
| 29 | int outer8(int); // expected-error{{redefinition of 'outer8' as different kind of symbol}} |
| 30 | float outer9; // expected-error{{redefinition of 'outer9' with a different type}} |
Douglas Gregor | d6f7e9d | 2009-02-24 20:03:32 +0000 | [diff] [blame] | 31 | |
| 32 | extern int outer13; // expected-note{{previous definition is here}} |
| 33 | void outer_shadowing_test() { |
| 34 | extern int outer10; |
| 35 | extern int outer11; // expected-note{{previous definition is here}} |
| 36 | extern int outer12; // expected-note{{previous definition is here}} |
| 37 | { |
| 38 | float outer10; |
| 39 | float outer11; |
| 40 | float outer12; |
| 41 | { |
| 42 | extern int outer10; // okay |
| 43 | extern float outer11; // expected-error{{redefinition of 'outer11' with a different type}} |
| 44 | static double outer12; |
| 45 | { |
| 46 | extern float outer12; // expected-error{{redefinition of 'outer12' with a different type}} |
| 47 | extern float outer13; // expected-error{{redefinition of 'outer13' with a different type}} |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | } |
Douglas Gregor | 6393519 | 2009-03-02 00:19:53 +0000 | [diff] [blame] | 52 | |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 53 | void g18(void) { // expected-note{{'g18' declared here}} |
Douglas Gregor | 6393519 | 2009-03-02 00:19:53 +0000 | [diff] [blame] | 54 | extern int g19; |
| 55 | } |
Douglas Gregor | bb092ba | 2009-12-31 05:20:13 +0000 | [diff] [blame] | 56 | int *p=&g19; // expected-error{{use of undeclared identifier 'g19'}} \ |
| 57 | // expected-warning{{incompatible pointer types}} |
Douglas Gregor | 5ef122e | 2009-03-19 22:01:50 +0000 | [diff] [blame] | 58 | |
| 59 | // PR3645 |
| 60 | static int a; |
Fariborz Jahanian | 2bf6d7b | 2010-06-21 16:08:37 +0000 | [diff] [blame] | 61 | extern int a; // expected-note {{previous definition is here}} |
| 62 | int a; // expected-error {{non-static declaration of 'a' follows static declaration}} |