[clang] [clang] Fix a crash issue that caused by handling of fields with initializers in nested anonymous unions (PR #113049)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 3 02:18:33 PST 2024
================
@@ -750,6 +750,18 @@ void InitListChecker::FillInEmptyInitForField(unsigned Init, FieldDecl *Field,
if (Field->hasInClassInitializer()) {
if (VerifyOnly)
return;
+
+ // We do not want to aggressively set the hadError flag and cutoff
+ // parsing. Try to recover when in-class-initializer is a RecoveryExpr.
+ if (isa_and_nonnull<RecoveryExpr>(Field->getInClassInitializer())) {
----------------
hokein wrote:
It is unclear to me why we need to check the specific `RecoveryExpr`? Can we just use the `Field->getInClassInitializer()->containsErrors()`?
https://github.com/llvm/llvm-project/pull/113049
More information about the cfe-commits
mailing list