summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2018-06-20 23:36:55 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2018-06-20 23:36:55 +0000
commit90ae9677e7825ef99ef8c3bd617882dbc73f81f8 (patch)
tree43a31c888144526d8994e673a4c03bdddf815ed1 /clang/lib/Sema/SemaDeclAttr.cpp
parent9dd5090086db99e649779b0333ea7c7a3a114a66 (diff)
downloadbcm5719-llvm-90ae9677e7825ef99ef8c3bd617882dbc73f81f8.tar.gz
bcm5719-llvm-90ae9677e7825ef99ef8c3bd617882dbc73f81f8.zip
When a dependent alignas is applied to a non-dependent typedef,
prioritize the error for the bad subject over the error for the dependent / non-dependent mismatch. llvm-svn: 335191
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 779192b8650..614432b0e23 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3440,16 +3440,6 @@ static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &AL) {
if (!AL.isPackExpansion() && S.DiagnoseUnexpandedParameterPack(E))
return;
- if (E->isValueDependent()) {
- if (const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
- if (!TND->getUnderlyingType()->isDependentType()) {
- S.Diag(AL.getLoc(), diag::err_alignment_dependent_typedef_name)
- << E->getSourceRange();
- return;
- }
- }
- }
-
S.AddAlignedAttr(AL.getRange(), D, E, AL.getAttributeSpellingListIndex(),
AL.isPackExpansion());
}
@@ -3496,7 +3486,18 @@ void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
}
}
- if (E->isTypeDependent() || E->isValueDependent()) {
+ if (E->isValueDependent()) {
+ // We can't support a dependent alignment on a non-dependent type,
+ // because we have no way to model that a type is "alignment-dependent"
+ // but not dependent in any other way.
+ if (const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
+ if (!TND->getUnderlyingType()->isDependentType()) {
+ Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
+ << E->getSourceRange();
+ return;
+ }
+ }
+
// Save dependent expressions in the AST to be instantiated.
AlignedAttr *AA = ::new (Context) AlignedAttr(TmpAttr);
AA->setPackExpansion(IsPackExpansion);
OpenPOWER on IntegriCloud