Skip to content

Commit c0be803

Browse files
committed
Move the error check into BuildCXXDefaultInit
Signed-off-by: yronglin <[email protected]>
1 parent ac30f8a commit c0be803

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5563,6 +5563,12 @@ 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+
55665572
// If we might have already tried and failed to instantiate, don't try again.
55675573
if (Field->isInvalidDecl())
55685574
return ExprError();

clang/lib/Sema/SemaInit.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -751,18 +751,6 @@ void InitListChecker::FillInEmptyInitForField(unsigned Init, FieldDecl *Field,
751751
if (VerifyOnly)
752752
return;
753753

754-
// We do not want to aggressively set the hadError flag and cutoff
755-
// parsing. Try to recover when in-class-initializer had errors.
756-
if (Field->getInClassInitializer() &&
757-
Field->getInClassInitializer()->containsErrors()) {
758-
if (Init < NumInits)
759-
ILE->setInit(Init, Field->getInClassInitializer());
760-
else
761-
ILE->updateInit(SemaRef.Context, Init,
762-
Field->getInClassInitializer());
763-
return;
764-
}
765-
766754
ExprResult DIE;
767755
{
768756
// Enter a default initializer rebuild context, then we can support

0 commit comments

Comments
 (0)