forked from OSchip/llvm-project
[AST][RecoveryExpr] Preserve the AST for invalid class constructions.
Differential Revision: https://reviews.llvm.org/D81090
This commit is contained in:
parent
ab7abd8bf4
commit
17ef788df5
|
@ -1389,6 +1389,9 @@ Sema::ActOnCXXTypeConstructExpr(ParsedType TypeRep,
|
||||||
if (!Result.isInvalid() && Result.get()->isInstantiationDependent() &&
|
if (!Result.isInvalid() && Result.get()->isInstantiationDependent() &&
|
||||||
!Result.get()->isTypeDependent())
|
!Result.get()->isTypeDependent())
|
||||||
Result = CorrectDelayedTyposInExpr(Result.get());
|
Result = CorrectDelayedTyposInExpr(Result.get());
|
||||||
|
else if (Result.isInvalid())
|
||||||
|
Result = CreateRecoveryExpr(TInfo->getTypeLoc().getBeginLoc(),
|
||||||
|
RParenOrBraceLoc, exprs, Ty);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,11 +157,14 @@ void InvalidInitalizer(int x) {
|
||||||
// CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
|
// CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
|
||||||
// CHECK-NEXT: `-InitListExpr
|
// CHECK-NEXT: `-InitListExpr
|
||||||
Bar b2 = {1};
|
Bar b2 = {1};
|
||||||
// FIXME: preserve the invalid initializer.
|
|
||||||
// CHECK: `-VarDecl {{.*}} b3 'Bar'
|
// CHECK: `-VarDecl {{.*}} b3 'Bar'
|
||||||
|
// CHECK-NEXT: `-RecoveryExpr {{.*}} 'Bar' contains-errors
|
||||||
|
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
|
||||||
Bar b3 = Bar(x);
|
Bar b3 = Bar(x);
|
||||||
// FIXME: preserve the invalid initializer.
|
|
||||||
// CHECK: `-VarDecl {{.*}} b4 'Bar'
|
// CHECK: `-VarDecl {{.*}} b4 'Bar'
|
||||||
|
// CHECK-NEXT: `-RecoveryExpr {{.*}} 'Bar' contains-errors
|
||||||
|
// CHECK-NEXT: `-InitListExpr {{.*}} 'void'
|
||||||
|
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
|
||||||
Bar b4 = Bar{x};
|
Bar b4 = Bar{x};
|
||||||
// CHECK: `-VarDecl {{.*}} b5 'Bar'
|
// CHECK: `-VarDecl {{.*}} b5 'Bar'
|
||||||
// CHECK-NEXT: `-CXXUnresolvedConstructExpr {{.*}} 'Bar' contains-errors 'Bar'
|
// CHECK-NEXT: `-CXXUnresolvedConstructExpr {{.*}} 'Bar' contains-errors 'Bar'
|
||||||
|
@ -174,6 +177,10 @@ void InvalidInitalizer(int x) {
|
||||||
// CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
|
// CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
|
||||||
// CHECK-NEXT: `-UnresolvedLookupExpr {{.*}} 'invalid'
|
// CHECK-NEXT: `-UnresolvedLookupExpr {{.*}} 'invalid'
|
||||||
Bar b6 = Bar{invalid()};
|
Bar b6 = Bar{invalid()};
|
||||||
|
|
||||||
|
// CHECK: `-RecoveryExpr {{.*}} 'Bar' contains-errors
|
||||||
|
// CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
|
||||||
|
Bar(1);
|
||||||
}
|
}
|
||||||
void InitializerForAuto() {
|
void InitializerForAuto() {
|
||||||
// CHECK: `-VarDecl {{.*}} invalid a 'auto'
|
// CHECK: `-VarDecl {{.*}} invalid a 'auto'
|
||||||
|
|
|
@ -2043,14 +2043,11 @@ namespace BadDefaultInit {
|
||||||
X<A().k>::n; // expected-note {{in evaluation of exception specification for 'BadDefaultInit::A::A' needed here}}
|
X<A().k>::n; // expected-note {{in evaluation of exception specification for 'BadDefaultInit::A::A' needed here}}
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: The "constexpr constructor must initialize all members" diagnostic
|
|
||||||
// here is bogus (we discard the k(k) initializer because the parameter 'k'
|
|
||||||
// has been marked invalid).
|
|
||||||
struct B {
|
struct B {
|
||||||
constexpr B( // expected-warning {{initialize all members}}
|
constexpr B(
|
||||||
int k = X<B().k>::n) : // expected-error {{default argument to function 'B' that is declared later}} expected-note {{here}}
|
int k = X<B().k>::n) : // expected-error {{default argument to function 'B' that is declared later}} expected-note {{here}}
|
||||||
k(k) {}
|
k(k) {}
|
||||||
int k; // expected-note {{not initialized}}
|
int k;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ namespace objects {
|
||||||
// (for the second phase, no constructor is viable)
|
// (for the second phase, no constructor is viable)
|
||||||
G g1{1, 2, 3}; // expected-error {{no matching constructor}}
|
G g1{1, 2, 3}; // expected-error {{no matching constructor}}
|
||||||
(void) new G{1, 2, 3}; // expected-error {{no matching constructor}}
|
(void) new G{1, 2, 3}; // expected-error {{no matching constructor}}
|
||||||
(void) G{1, 2, 3} // expected-error {{no matching constructor}}
|
(void) G{1, 2, 3}; // expected-error {{no matching constructor}}
|
||||||
|
|
||||||
// valid (T deduced to <>).
|
// valid (T deduced to <>).
|
||||||
G g2({1, 2, 3});
|
G g2({1, 2, 3});
|
||||||
|
|
|
@ -106,7 +106,7 @@ void test_expressions(bool b) {
|
||||||
sizeof(Indestructible{}); // expected-error {{deleted}}
|
sizeof(Indestructible{}); // expected-error {{deleted}}
|
||||||
sizeof(make_indestructible()); // expected-error {{deleted}}
|
sizeof(make_indestructible()); // expected-error {{deleted}}
|
||||||
sizeof(make_incomplete()); // expected-error {{incomplete}}
|
sizeof(make_incomplete()); // expected-error {{incomplete}}
|
||||||
typeid(Indestructible{}); // expected-error {{deleted}}
|
typeid(Indestructible{}); // expected-error {{deleted}} expected-error {{you need to include <typeinfo>}}
|
||||||
typeid(make_indestructible()); // expected-error {{deleted}} \
|
typeid(make_indestructible()); // expected-error {{deleted}} \
|
||||||
// expected-error {{need to include <typeinfo>}}
|
// expected-error {{need to include <typeinfo>}}
|
||||||
typeid(make_incomplete()); // expected-error {{incomplete}} \
|
typeid(make_incomplete()); // expected-error {{incomplete}} \
|
||||||
|
|
Loading…
Reference in New Issue