]> granicus.if.org Git - clang/commitdiff
Fixes a regression when redeclaration of a global satic
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 24 Jun 2010 18:50:41 +0000 (18:50 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 24 Jun 2010 18:50:41 +0000 (18:50 +0000)
is an extern local to a function. Radar 8125274.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106773 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/extern-redecl.c [new file with mode: 0644]

index ebfb9810d6608a3f6658255ac29962d3b1426ca5..5c1de6aeb8805f6724a7bb77bc70d71824b66317 100644 (file)
@@ -1456,7 +1456,8 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) {
   }
 
   if (New->hasExternalStorage() &&
-      Old->getLinkage() == InternalLinkage)
+      Old->getLinkage() == InternalLinkage &&
+      New->getDeclContext() == Old->getDeclContext())
     New->setStorageClass(Old->getStorageClass());
 
   // Keep a chain of previous declarations.
diff --git a/test/Sema/extern-redecl.c b/test/Sema/extern-redecl.c
new file mode 100644 (file)
index 0000000..067e3c2
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+// rdar: // 8125274
+static int a16[];  // expected-warning {{tentative array definition assumed to have one element}}
+
+void f16(void) {
+    extern int a16[];
+}
+