From: Steve Naroff Date: Wed, 17 Sep 2008 14:05:40 +0000 (+0000) Subject: Fix http://llvm.org/bugs/show_bug.cgi?id=2760. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=094cefbcc48c6b29062fef343fa8ff78ad368713;p=clang Fix http://llvm.org/bugs/show_bug.cgi?id=2760. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56280 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 2f4350766a..db1a7aef8b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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); } diff --git a/test/Sema/tentative-decls.c b/test/Sema/tentative-decls.c index 288757af87..3a2fd5a235 100644 --- a/test/Sema/tentative-decls.c +++ b/test/Sema/tentative-decls.c @@ -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; +}