summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-24 19:23:27 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-24 19:23:27 +0000
commit5d68a20949723c4725b64d63472b3da2f44f5fe4 (patch)
tree51cf6b1bf8887488a8a3011f4913947807a9ceeb /clang/test
parentc52f9394ce1dd59a4f57e3f6cef34fb7679e3a5a (diff)
downloadbcm5719-llvm-5d68a20949723c4725b64d63472b3da2f44f5fe4.tar.gz
bcm5719-llvm-5d68a20949723c4725b64d63472b3da2f44f5fe4.zip
Extend the implicit declaration and checking against out-of-scope
external declarations to also support external variable declarations. Unified the code for these two cases into two new subroutines. Note that we fail to diagnose cases like the one Neil pointed out, where a visible non-external declaration hides an external declaration by the same name. That will require some reshuffling of name lookup. llvm-svn: 65385
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Sema/var-redecl.c30
-rw-r--r--clang/test/Sema/vla.c6
2 files changed, 33 insertions, 3 deletions
diff --git a/clang/test/Sema/var-redecl.c b/clang/test/Sema/var-redecl.c
new file mode 100644
index 00000000000..9abe2731c08
--- /dev/null
+++ b/clang/test/Sema/var-redecl.c
@@ -0,0 +1,30 @@
+// RUN: clang -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}}
diff --git a/clang/test/Sema/vla.c b/clang/test/Sema/vla.c
index 4b7a746b463..30c20bd93bd 100644
--- a/clang/test/Sema/vla.c
+++ b/clang/test/Sema/vla.c
@@ -19,9 +19,9 @@ int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a cons
// PR2352
void f2(unsigned int m)
{
- extern int e[2][m]; // expected-error {{variable length array declaration can not have 'extern' linkage}}
+ extern int e1[2][m]; // expected-error {{variable length array declaration can not have 'extern' linkage}}
- e[0][0] = 0;
+ e1[0][0] = 0;
}
@@ -37,7 +37,7 @@ void f3()
static int a[i]; // expected-error {{variable length array declaration can not have 'static' storage duration}}
extern int b[i]; // expected-error {{variable length array declaration can not have 'extern' linkage}}
- extern int (*c)[i]; // expected-error {{variably modified type declaration can not have 'extern' linkage}}
+ extern int (*c1)[i]; // expected-error {{variably modified type declaration can not have 'extern' linkage}}
static int (*d)[i];
}
OpenPOWER on IntegriCloud