[cfe-commits] r51005 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/tentative-decls.c
Steve Naroff
snaroff at apple.com
Mon May 12 15:36:44 PDT 2008
Author: snaroff
Date: Mon May 12 17:36:43 2008
New Revision: 51005
URL: http://llvm.org/viewvc/llvm-project?rev=51005&view=rev
Log:
Fix <rdar://problem/5924576> clang -fsyntax-only generates "redefinition" errors when parsing AppKit that gcc does not.
Teach Sema::MergeVarDecl() about __private_extern__.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/tentative-decls.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=51005&r1=51004&r2=51005&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May 12 17:36:43 2008
@@ -441,8 +441,11 @@
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);
}
Modified: cfe/trunk/test/Sema/tentative-decls.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/tentative-decls.c?rev=51005&r1=51004&r2=51005&view=diff
==============================================================================
--- cfe/trunk/test/Sema/tentative-decls.c (original)
+++ cfe/trunk/test/Sema/tentative-decls.c Mon May 12 17:36:43 2008
@@ -18,6 +18,9 @@
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}}
More information about the cfe-commits
mailing list