forked from OSchip/llvm-project
[AST][RecoveryExpr] Fix a crash on a field decl with invalid type.
Summary: The field decl (in the testcase) was still valid, which results in a valid RecordDecl, it led to crash when performing struct layout, and computing struct size etc. Reviewers: sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81913
This commit is contained in:
parent
b7084d8ede
commit
28923dc2dd
|
@ -16479,7 +16479,7 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T,
|
|||
|
||||
// If we receive a broken type, recover by assuming 'int' and
|
||||
// marking this declaration as invalid.
|
||||
if (T.isNull()) {
|
||||
if (T.isNull() || T->containsErrors()) {
|
||||
InvalidDecl = true;
|
||||
T = Context.IntTy;
|
||||
}
|
||||
|
|
|
@ -13,3 +13,9 @@ class Y {
|
|||
};
|
||||
// Should be able to evaluate sizeof without crashing.
|
||||
static_assert(sizeof(Y) == 1, "No valid members");
|
||||
|
||||
class Z {
|
||||
int array[sizeof(invalid())]; // expected-error {{use of undeclared identifier}}
|
||||
};
|
||||
// Should be able to evaluate sizeof without crashing.
|
||||
static_assert(sizeof(Z) == 1, "No valid members");
|
||||
|
|
Loading…
Reference in New Issue