File tree Expand file tree Collapse file tree 5 files changed +29
-4
lines changed Expand file tree Collapse file tree 5 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,10 @@ ExprDependence clang::computeDependence(UnaryExprOrTypeTraitExpr *E) {
7171 if (!D)
7272 return Deps;
7373 for (const auto *I : D->specific_attrs <AlignedAttr>()) {
74+ if (I->isAlignmentErrorDependent ())
75+ Deps |= ExprDependence::Error;
7476 if (I->isAlignmentDependent ())
75- return Deps | ExprDependence::ValueInstantiation;
77+ Deps |= ExprDependence::ValueInstantiation;
7678 }
7779 return Deps;
7880}
Original file line number Diff line number Diff line change @@ -396,8 +396,10 @@ unsigned Decl::getMaxAlignment() const {
396396 const AttrVec &V = getAttrs ();
397397 ASTContext &Ctx = getASTContext ();
398398 specific_attr_iterator<AlignedAttr> I (V.begin ()), E (V.end ());
399- for (; I != E; ++I)
400- Align = std::max (Align, I->getAlignment (Ctx));
399+ for (; I != E; ++I) {
400+ if (!I->isAlignmentErrorDependent ())
401+ Align = std::max (Align, I->getAlignment (Ctx));
402+ }
401403 return Align;
402404}
403405
Original file line number Diff line number Diff line change @@ -97,4 +97,9 @@ struct Foo {} foo;
9797void test (int x) {
9898 foo.abc ;
9999 foo->func (x);
100- }
100+ }
101+
102+ // CHECK: |-AlignedAttr {{.*}} alignas
103+ // CHECK-NEXT:| `-RecoveryExpr {{.*}} contains-errors
104+ // CHECK-NEXT:| `-UnresolvedLookupExpr {{.*}} 'invalid'
105+ struct alignas (invalid()) Aligned {};
Original file line number Diff line number Diff line change 1+ // RUN: %clang_cc1 -frecovery-ast -verify %s
2+ // RUN: %clang_cc1 -verify %s
3+
4+ struct alignas (invalid()) Foo {}; // expected-error {{use of undeclared identifier}}
5+
6+ constexpr int k = alignof (Foo);
Original file line number Diff line number Diff line change @@ -481,6 +481,7 @@ namespace {
481481
482482 void writeAccessors (raw_ostream &OS) const override {
483483 OS << " bool is" << getUpperName () << " Dependent() const;\n " ;
484+ OS << " bool is" << getUpperName () << " ErrorDependent() const;\n " ;
484485
485486 OS << " unsigned get" << getUpperName () << " (ASTContext &Ctx) const;\n " ;
486487
@@ -511,6 +512,15 @@ namespace {
511512 << " Type->getType()->isDependentType();\n " ;
512513 OS << " }\n " ;
513514
515+ OS << " bool " << getAttrName () << " Attr::is" << getUpperName ()
516+ << " ErrorDependent() const {\n " ;
517+ OS << " if (is" << getLowerName () << " Expr)\n " ;
518+ OS << " return " << getLowerName () << " Expr && " << getLowerName ()
519+ << " Expr->containsErrors();\n " ;
520+ OS << " return " << getLowerName ()
521+ << " Type->getType()->containsErrors();\n " ;
522+ OS << " }\n " ;
523+
514524 // FIXME: Do not do the calculation here
515525 // FIXME: Handle types correctly
516526 // A null pointer means maximum alignment
You can’t perform that action at this time.
0 commit comments