[cfe-commits] [PATCH] Fix isThisDeclarationADefinition for extern following tentative.
Rafael Ávila de Espíndola
rafael.espindola at gmail.com
Sat Dec 15 15:50:07 PST 2012
An extern declaration following a tentative definition should not itself be
considered a tentative definition.
Fixes pr14614.
---
lib/AST/Decl.cpp | 2 +-
test/Sema/extern-redecl.c | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 538dcee..4e4bc0e 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -1220,7 +1220,7 @@ VarDecl::DefinitionKind VarDecl::isThisDeclarationADefinition(
getStorageClassAsWritten() == SC_PrivateExtern) {
for (const VarDecl *PrevVar = getPreviousDecl();
PrevVar; PrevVar = PrevVar->getPreviousDecl()) {
- if (PrevVar->getLinkage() == InternalLinkage && PrevVar->hasInit())
+ if (PrevVar->getLinkage() == InternalLinkage)
return DeclarationOnly;
}
}
diff --git a/test/Sema/extern-redecl.c b/test/Sema/extern-redecl.c
index c176725..ae4386e 100644
--- a/test/Sema/extern-redecl.c
+++ b/test/Sema/extern-redecl.c
@@ -20,3 +20,5 @@ int PR10013(void) {
return PR10013_x; // expected-warning{{incompatible pointer to integer conversion}}
}
+static int test1_a[]; // expected-warning {{tentative array definition assumed to have one element}}
+extern int test1_a[];
--
1.7.11.7
More information about the cfe-commits
mailing list