diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -338,6 +338,8 @@ - Fix crash when attempting to perform parenthesized initialization of an aggregate with a base class with only non-public constructors. (`#62296 `_) +- Fix crash when redefine variant with invalid type as another invalid type. + (`#62447 `_) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2546,6 +2546,9 @@ return QualType(); } + if (!getLangOpts().CPlusPlus && ArraySize && ArraySize->containsErrors()) + return QualType(); + // VLAs always produce at least a -Wvla diagnostic, sometimes an error. unsigned VLADiag; bool VLAIsError; diff --git a/clang/test/Sema/merge-decls.c b/clang/test/Sema/merge-decls.c --- a/clang/test/Sema/merge-decls.c +++ b/clang/test/Sema/merge-decls.c @@ -91,3 +91,7 @@ int x[5]; test7_f(&x); // expected-warning {{incompatible pointer types passing 'int (*)[5]' to parameter of type 'int (*)[10]}} } + +char d; +char x[sizeof(d.data) == 8]; // expected-error {{member reference base type 'char' is not a structure or union}} +char x[sizeof(d.data) == 4]; // expected-error {{member reference base type 'char' is not a structure or union}}