summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorNico Rieck <nico.rieck@gmail.com>2014-01-21 23:54:36 +0000
committerNico Rieck <nico.rieck@gmail.com>2014-01-21 23:54:36 +0000
commitf8e8b5f5c29678288f1a71bd2f14a3ba6843b112 (patch)
treee119498c5bcdf004603129d5ab4e0e0a902731de /clang/lib/Sema/SemaDecl.cpp
parent601b22c37741559037cfb1b75d9331ed3481bc76 (diff)
downloadbcm5719-llvm-f8e8b5f5c29678288f1a71bd2f14a3ba6843b112.tar.gz
bcm5719-llvm-f8e8b5f5c29678288f1a71bd2f14a3ba6843b112.zip
Delay attribute checking until auto types are deduced
Checking in ActOnVariableDeclarator computes and caches the linkage using the non-deduced auto type which defaults to external linkage. Depending on how the auto type is deduced linkage can change and conflict with the cached linkage, hitting asserts. llvm-svn: 199774
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index f7b7ac87ec9..c08d87d59a8 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4816,6 +4816,10 @@ bool Sema::inferObjCARCLifetime(ValueDecl *decl) {
}
static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) {
+ // Ensure that an auto decl is deduced otherwise the checks below might cache
+ // the wrong linkage.
+ assert(S.ParsingInitForAutoVars.count(&ND) == 0);
+
// 'weak' only applies to declarations with external linkage.
if (WeakAttr *Attr = ND.getAttr<WeakAttr>()) {
if (!ND.isExternallyVisible()) {
@@ -5431,7 +5435,6 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
}
ProcessPragmaWeak(S, NewVD);
- checkAttributesAfterMerging(*this, *NewVD);
// If this is the first declaration of an extern C variable, update
// the map of such variables.
@@ -8892,6 +8895,8 @@ Sema::FinalizeDeclaration(Decl *ThisDecl) {
if (!VD)
return;
+ checkAttributesAfterMerging(*this, *VD);
+
if (UsedAttr *Attr = VD->getAttr<UsedAttr>()) {
if (!Attr->isInherited() && !VD->isThisDeclarationADefinition()) {
Diag(Attr->getLocation(), diag::warn_attribute_ignored) << Attr;
OpenPOWER on IntegriCloud