Commit 17198df 1 parent c3c67e9 commit 17198df Copy full SHA for 17198df
File tree 5 files changed +29
-4
lines changed
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) {
71
71
if (!D)
72
72
return Deps;
73
73
for (const auto *I : D->specific_attrs <AlignedAttr>()) {
74
+ if (I->isAlignmentErrorDependent ())
75
+ Deps |= ExprDependence::Error;
74
76
if (I->isAlignmentDependent ())
75
- return Deps | ExprDependence::ValueInstantiation;
77
+ Deps |= ExprDependence::ValueInstantiation;
76
78
}
77
79
return Deps;
78
80
}
Original file line number Diff line number Diff line change @@ -396,8 +396,10 @@ unsigned Decl::getMaxAlignment() const {
396
396
const AttrVec &V = getAttrs ();
397
397
ASTContext &Ctx = getASTContext ();
398
398
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
+ }
401
403
return Align;
402
404
}
403
405
Original file line number Diff line number Diff line change @@ -97,4 +97,9 @@ struct Foo {} foo;
97
97
void test (int x) {
98
98
foo.abc ;
99
99
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 {
481
481
482
482
void writeAccessors (raw_ostream &OS) const override {
483
483
OS << " bool is" << getUpperName () << " Dependent() const;\n " ;
484
+ OS << " bool is" << getUpperName () << " ErrorDependent() const;\n " ;
484
485
485
486
OS << " unsigned get" << getUpperName () << " (ASTContext &Ctx) const;\n " ;
486
487
@@ -511,6 +512,15 @@ namespace {
511
512
<< " Type->getType()->isDependentType();\n " ;
512
513
OS << " }\n " ;
513
514
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
+
514
524
// FIXME: Do not do the calculation here
515
525
// FIXME: Handle types correctly
516
526
// A null pointer means maximum alignment
You can’t perform that action at this time.
0 commit comments