]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/5924576> clang -fsyntax-only generates "redefinition" errors...
authorSteve Naroff <snaroff@apple.com>
Mon, 12 May 2008 22:36:43 +0000 (22:36 +0000)
committerSteve Naroff <snaroff@apple.com>
Mon, 12 May 2008 22:36:43 +0000 (22:36 +0000)
Teach Sema::MergeVarDecl() about __private_extern__.

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

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

index 933a3618120079840230f30726e94bfa71deb524..26fbafdd408987ddbd6484550e04768399de785d 100644 (file)
@@ -441,8 +441,11 @@ VarDecl *Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
     if (NewIsTentative || OldIsTentative)
       return New;
   }
+  // Handle __private_extern__ just like extern.
   if (Old->getStorageClass() != VarDecl::Extern &&
-      New->getStorageClass() != VarDecl::Extern) {
+      Old->getStorageClass() != VarDecl::PrivateExtern &&
+      New->getStorageClass() != VarDecl::Extern &&
+      New->getStorageClass() != VarDecl::PrivateExtern) {
     Diag(New->getLocation(), diag::err_redefinition, New->getName());
     Diag(Old->getLocation(), diag::err_previous_definition);
   }
index 0c390fe4144bc62d43e7b752177308ae5c72a7ee..6e79a0868fd4aa9eb2539a6753947e989028fa03 100644 (file)
@@ -18,6 +18,9 @@ extern int i1; // expected-error{{previous definition is here}}
 static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}} expected-error{{previous definition is here}}
 int i1 = 3; // expected-error{{non-static declaration of 'i1' follows static declaration}}
 
+__private_extern__ int pExtern;
+int pExtern = 0;
+
 void func() {
   extern int i1; // expected-error{{previous definition is here}}
   static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}}