]> granicus.if.org Git - clang/commitdiff
Fix http://llvm.org/bugs/show_bug.cgi?id=2760.
authorSteve Naroff <snaroff@apple.com>
Wed, 17 Sep 2008 14:05:40 +0000 (14:05 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 17 Sep 2008 14:05:40 +0000 (14:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56280 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/tentative-decls.c

index 2f4350766ac9e0619ebb634d38bbe7d8469604b1..db1a7aef8b141afa3a4757ceb6fc8274b33e202b 100644 (file)
@@ -464,8 +464,8 @@ VarDecl *Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
     Diag(Old->getLocation(), diag::err_previous_definition);
     return New;
   }
-  // File scoped variables are analyzed in FinalizeDeclaratorGroup.
-  if (!New->isFileVarDecl()) {
+  // Variables with external linkage are analyzed in FinalizeDeclaratorGroup.
+  if (New->getStorageClass() != VarDecl::Extern && !New->isFileVarDecl()) {
     Diag(New->getLocation(), diag::err_redefinition, New->getName());
     Diag(Old->getLocation(), diag::err_previous_definition);
   }
index 288757af87285eda2027d1705ce153adbb2457a3..3a2fd5a235d4ed0078d26c6b31170bdfa0237f0c 100644 (file)
@@ -35,3 +35,9 @@ void func() {
   extern int i1; // expected-error{{previous definition is here}}
   static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}}
 }
+
+void func2(void)
+{
+  extern double *p;
+  extern double *p;
+}