diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/Sema/var-redecl.c | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/Sema/var-redecl.c')
-rw-r--r-- | clang/test/Sema/var-redecl.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/clang/test/Sema/var-redecl.c b/clang/test/Sema/var-redecl.c new file mode 100644 index 0000000..f7576b6 --- /dev/null +++ b/clang/test/Sema/var-redecl.c @@ -0,0 +1,62 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +int outer1; // expected-note{{previous definition is here}} +extern int outer2; // expected-note{{previous definition is here}} +int outer4; +int outer4; // expected-note{{previous definition is here}} +int outer5; +int outer6(float); // expected-note{{previous definition is here}} +int outer7(float); + +void outer_test() { + extern float outer1; // expected-error{{redefinition of 'outer1' with a different type}} + extern float outer2; // expected-error{{redefinition of 'outer2' with a different type}} + extern float outer3; // expected-note{{previous definition is here}} + double outer4; + extern int outer5; // expected-note{{previous definition is here}} + extern int outer6; // expected-error{{redefinition of 'outer6' as different kind of symbol}} + int outer7; + extern int outer8; // expected-note{{previous definition is here}} + extern int outer9; + { + extern int outer9; // expected-note{{previous definition is here}} + } +} + +int outer3; // expected-error{{redefinition of 'outer3' with a different type}} +float outer4; // expected-error{{redefinition of 'outer4' with a different type}} +float outer5; // expected-error{{redefinition of 'outer5' with a different type}} +int outer8(int); // expected-error{{redefinition of 'outer8' as different kind of symbol}} +float outer9; // expected-error{{redefinition of 'outer9' with a different type}} + +extern int outer13; // expected-note{{previous definition is here}} +void outer_shadowing_test() { + extern int outer10; + extern int outer11; // expected-note{{previous definition is here}} + extern int outer12; // expected-note{{previous definition is here}} + { + float outer10; + float outer11; + float outer12; + { + extern int outer10; // okay + extern float outer11; // expected-error{{redefinition of 'outer11' with a different type}} + static double outer12; + { + extern float outer12; // expected-error{{redefinition of 'outer12' with a different type}} + extern float outer13; // expected-error{{redefinition of 'outer13' with a different type}} + } + } + } +} + +void g18(void) { // expected-note{{'g18' declared here}} + extern int g19; +} +int *p=&g19; // expected-error{{use of undeclared identifier 'g19'}} \ + // expected-warning{{incompatible pointer types}} + +// PR3645 +static int a; +extern int a; // expected-note {{previous definition is here}} +int a; // expected-error {{non-static declaration of 'a' follows static declaration}} |