HerrCai0907 updated this revision to Diff 519972. HerrCai0907 added a comment.
update Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149612/new/ https://reviews.llvm.org/D149612 Files: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaType.cpp clang/test/AST/ast-dump-types-errors-json.cpp clang/test/AST/ast-dump-types-errors.cpp clang/test/Sema/merge-decls.c
Index: clang/test/Sema/merge-decls.c =================================================================== --- clang/test/Sema/merge-decls.c +++ 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}} Index: clang/test/AST/ast-dump-types-errors.cpp =================================================================== --- clang/test/AST/ast-dump-types-errors.cpp +++ clang/test/AST/ast-dump-types-errors.cpp @@ -2,5 +2,5 @@ void test() { using ContainsErrors = int[sizeof(undef())]; - // CHECK: DependentSizedArrayType {{.*}} contains-errors dependent + // CHECK: ConstantArrayType {{.*}} 'int[0]' contains-errors dependent 0 } Index: clang/test/AST/ast-dump-types-errors-json.cpp =================================================================== --- clang/test/AST/ast-dump-types-errors-json.cpp +++ clang/test/AST/ast-dump-types-errors-json.cpp @@ -24,18 +24,19 @@ // CHECK-NEXT: }, // CHECK-NEXT: "name": "TestContainsErrors", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "int[sizeof (<recovery-expr>(undef))]" +// CHECK-NEXT: "qualType": "int[0]" // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ // CHECK-NEXT: { // CHECK-NEXT: "id": "0x{{.*}}", -// CHECK-NEXT: "kind": "DependentSizedArrayType", +// CHECK-NEXT: "kind": "ConstantArrayType", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "int[sizeof (<recovery-expr>(undef))]" +// CHECK-NEXT: "qualType": "int[0]" // CHECK-NEXT: }, // CHECK-NEXT: "containsErrors": true, // CHECK-NEXT: "isDependent": true, // CHECK-NEXT: "isInstantiationDependent": true, +// CHECK-NEXT: "size": 0, // CHECK-NEXT: "inner": [ // CHECK-NEXT: { // CHECK-NEXT: "id": "0x{{.*}}", @@ -43,96 +44,6 @@ // CHECK-NEXT: "type": { // CHECK-NEXT: "qualType": "int" // CHECK-NEXT: } -// CHECK-NEXT: }, -// CHECK-NEXT: { -// CHECK-NEXT: "id": "0x{{.*}}", -// CHECK-NEXT: "kind": "UnaryExprOrTypeTraitExpr", -// CHECK-NEXT: "range": { -// CHECK-NEXT: "begin": { -// CHECK-NEXT: "offset": {{[0-9]+}}, -// CHECK-NEXT: "col": 32, -// CHECK-NEXT: "tokLen": 6 -// CHECK-NEXT: }, -// CHECK-NEXT: "end": { -// CHECK-NEXT: "offset": {{[0-9]+}}, -// CHECK-NEXT: "col": 46, -// CHECK-NEXT: "tokLen": 1 -// CHECK-NEXT: } -// CHECK-NEXT: }, -// CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "unsigned long" -// CHECK-NEXT: }, -// CHECK-NEXT: "valueCategory": "prvalue", -// CHECK-NEXT: "name": "sizeof", -// CHECK-NEXT: "inner": [ -// CHECK-NEXT: { -// CHECK-NEXT: "id": "0x{{.*}}", -// CHECK-NEXT: "kind": "ParenExpr", -// CHECK-NEXT: "range": { -// CHECK-NEXT: "begin": { -// CHECK-NEXT: "offset": {{[0-9]+}}, -// CHECK-NEXT: "col": 38, -// CHECK-NEXT: "tokLen": 1 -// CHECK-NEXT: }, -// CHECK-NEXT: "end": { -// CHECK-NEXT: "offset": {{[0-9]+}}, -// CHECK-NEXT: "col": 46, -// CHECK-NEXT: "tokLen": 1 -// CHECK-NEXT: } -// CHECK-NEXT: }, -// CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "<dependent type>" -// CHECK-NEXT: }, -// CHECK-NEXT: "valueCategory": "lvalue", -// CHECK-NEXT: "inner": [ -// CHECK-NEXT: { -// CHECK-NEXT: "id": "0x{{.*}}", -// CHECK-NEXT: "kind": "RecoveryExpr", -// CHECK-NEXT: "range": { -// CHECK-NEXT: "begin": { -// CHECK-NEXT: "offset": {{[0-9]+}}, -// CHECK-NEXT: "col": 39, -// CHECK-NEXT: "tokLen": 5 -// CHECK-NEXT: }, -// CHECK-NEXT: "end": { -// CHECK-NEXT: "offset": {{[0-9]+}}, -// CHECK-NEXT: "col": 45, -// CHECK-NEXT: "tokLen": 1 -// CHECK-NEXT: } -// CHECK-NEXT: }, -// CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "<dependent type>" -// CHECK-NEXT: }, -// CHECK-NEXT: "valueCategory": "lvalue", -// CHECK-NEXT: "inner": [ -// CHECK-NEXT: { -// CHECK-NEXT: "id": "0x{{.*}}", -// CHECK-NEXT: "kind": "UnresolvedLookupExpr", -// CHECK-NEXT: "range": { -// CHECK-NEXT: "begin": { -// CHECK-NEXT: "offset": {{[0-9]+}}, -// CHECK-NEXT: "col": 39, -// CHECK-NEXT: "tokLen": 5 -// CHECK-NEXT: }, -// CHECK-NEXT: "end": { -// CHECK-NEXT: "offset": {{[0-9]+}}, -// CHECK-NEXT: "col": 39, -// CHECK-NEXT: "tokLen": 5 -// CHECK-NEXT: } -// CHECK-NEXT: }, -// CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "<overloaded function type>" -// CHECK-NEXT: }, -// CHECK-NEXT: "valueCategory": "lvalue", -// CHECK-NEXT: "usesADL": true, -// CHECK-NEXT: "name": "undef", -// CHECK-NEXT: "lookups": [] -// CHECK-NEXT: } -// CHECK-NEXT: ] -// CHECK-NEXT: } -// CHECK-NEXT: ] -// CHECK-NEXT: } -// CHECK-NEXT: ] // CHECK-NEXT: } // CHECK-NEXT: ] // CHECK-NEXT: } Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -2579,7 +2579,15 @@ T = Context.getIncompleteArrayType(T, ASM, Quals); } } else if (ArraySize->isTypeDependent() || ArraySize->isValueDependent()) { - T = Context.getDependentSizedArrayType(T, ArraySize, ASM, Quals, Brackets); + if (ArraySize->containsErrors()) { + RecoveryExpr *RE = RecoveryExpr::Create( + Context, ArraySize->getType(), ArraySize->getBeginLoc(), + ArraySize->getEndLoc(), ArrayRef<Expr *>{}); + T = Context.getConstantArrayType(T, ConstVal, RE, ASM, Quals); + } else { + T = Context.getDependentSizedArrayType(T, ArraySize, ASM, Quals, + Brackets); + } } else { ExprResult R = checkArraySize(*this, ArraySize, ConstVal, VLADiag, VLAIsError); Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -369,6 +369,8 @@ (`#62207 <https://github.com/llvm/llvm-project/issues/62207>`_) - Fix lambdas and other anonymous function names not respecting ``-fdebug-prefix-map`` (`#62192 <https://github.com/llvm/llvm-project/issues/62192>`_) +- Fix crash when redefine variant with invalid type as another invalid type. + (`#62447 <https://github.com/llvm/llvm-project/issues/62447>`_) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits