Skip to content

Commit 5be9331

Browse files
committed
Build invalid default-member-init in BuildCXXDefaultInitExpr
Signed-off-by: yronglin <[email protected]>
1 parent c0be803 commit 5be9331

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5563,16 +5563,6 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
55635563
ExprResult Sema::BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field) {
55645564
assert(Field->hasInClassInitializer());
55655565

5566-
// We do not want to aggressively cutoff parsing. Try to recover when
5567-
// in-class-initializer had errors.
5568-
if (Field->getInClassInitializer() &&
5569-
Field->getInClassInitializer()->containsErrors())
5570-
return Field->getInClassInitializer();
5571-
5572-
// If we might have already tried and failed to instantiate, don't try again.
5573-
if (Field->isInvalidDecl())
5574-
return ExprError();
5575-
55765566
CXXThisScopeRAII This(*this, Field->getParent(), Qualifiers());
55775567

55785568
auto *ParentRD = cast<CXXRecordDecl>(Field->getParent());

clang/test/AST/ast-dump-recovery.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ union U {
487487
// CHECK-NEXT: `-DeclStmt {{.*}}
488488
// CHECK-NEXT: `-VarDecl {{.*}} g 'U':'GH112560::U' listinit
489489
// CHECK-NEXT: `-InitListExpr {{.*}} 'U':'GH112560::U' contains-errors field Field {{.*}} 'f' 'int'
490-
// CHECK-NEXT: `-RecoveryExpr {{.*}} 'int' contains-errors
490+
// CHECK-NEXT: `-CXXDefaultInitExpr {{.*}} 'int' contains-errors has rewritten init
491+
// CHECK-NEXT: `-RecoveryExpr {{.*}} 'int' contains-errors
491492
// DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
492493
void foo() {
493494
U g{};

0 commit comments

Comments
 (0)