]> granicus.if.org Git - clang/commitdiff
Thanks to Eli for pointing out my misreading of 6.2.2p5
authorDouglas Gregor <dgregor@apple.com>
Mon, 23 Mar 2009 16:17:01 +0000 (16:17 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 23 Mar 2009 16:17:01 +0000 (16:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67530 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 255fd6c5ba49e9743b640ae818988c430af7440d..62b9bff3defa12001d96508956c7f38b8f58ee69 100644 (file)
@@ -841,8 +841,7 @@ bool Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
   //   the prior declaration. If no prior declaration is visible, or
   //   if the prior declaration specifies no linkage, then the
   //   identifier has external linkage.
-  if ((New->hasExternalStorage() || New->getStorageClass() == VarDecl::None) &&
-      Old->hasLinkage())
+  if (New->hasExternalStorage() && Old->hasLinkage())
     /* Okay */;
   else if (New->getStorageClass() != VarDecl::Static &&
            Old->getStorageClass() == VarDecl::Static) {
index fc0d50086eaa72c87b01f076f8512c517504bf13..ea8d622551086927ad893dd0d9794b4f9e2ce470 100644 (file)
@@ -27,7 +27,10 @@ extern int i1; // expected-note {{previous definition is here}}
 static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}}
 
 static int i2 = 5; // expected-note 1 {{previous definition is here}}
-int i2 = 3; // expected-error{{redefinition of 'i2'}}
+int i2 = 3; // expected-error{{non-static declaration of 'i2' follows static declaration}}
+
+static int i3 = 5;
+extern int i3;
 
 __private_extern__ int pExtern;
 int pExtern = 0;