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 2f43507..db1a7ae 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -464,8 +464,8 @@
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 288757a..3a2fd5a 100644
--- a/test/Sema/tentative-decls.c
+++ b/test/Sema/tentative-decls.c
@@ -35,3 +35,9 @@
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;
+}