[Clang] prevent setting default lexical access specifier for missing primary declarations (#112424)

This PR resolves a crash triggered by a forward reference to an enum
type in a function parameter list. The fix includes setting `Invalid`
when `TagUseKind` is `Declaration` to ensure correct error handling.

Fixes #112208
This commit is contained in:
Oleksandr T. 2024-11-01 07:13:33 +02:00 committed by GitHub
parent 8e3772744d
commit df9769e14b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 0 deletions

View File

@ -589,6 +589,7 @@ Bug Fixes to C++ Support
- Fixed an assertion failure in range calculations for conditional throw expressions. (#GH111854)
- Clang now correctly ignores previous partial specializations of member templates explicitly specialized for
an implicitly instantiated class template specialization. (#GH51051)
- Fixed an assertion failure caused by invalid enum forward declarations. (#GH112208)
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -17955,6 +17955,8 @@ CreateNewDecl:
<< Name;
Invalid = true;
}
if (TUK == TagUseKind::Declaration)
Invalid = true;
} else if (!PrevDecl) {
Diag(Loc, diag::warn_decl_in_param_list) << Context.getTagDeclType(New);
}

View File

@ -143,3 +143,11 @@ struct PR28903 {
})
};
};
namespace GH112208 {
class C {
enum E { e = 0 };
void f(int, enum E;); // expected-error {{ISO C++ forbids forward references to 'enum' types}} \
// expected-error {{unexpected ';' before ')'}}
};
}