https://github.com/Fznamznon updated https://github.com/llvm/llvm-project/pull/119402
>From 9c168204ffa0c23d8138eb1780a0ec54cb29f1c6 Mon Sep 17 00:00:00 2001 From: "Podchishchaeva, Mariya" <mariya.podchishcha...@intel.com> Date: Tue, 10 Dec 2024 07:50:56 -0800 Subject: [PATCH 1/2] [clang] Reject `_Complex _BitInt` The C standard doesn't require support for these types and Codegen for these types is incorrect ATM. See https://github.com/llvm/llvm-project/issues/119352 --- clang/docs/ReleaseNotes.rst | 2 ++ clang/lib/Sema/DeclSpec.cpp | 3 +-- clang/test/AST/ByteCode/complex.cpp | 8 -------- clang/test/CodeGenCXX/ext-int.cpp | 18 ------------------ clang/test/SemaCXX/ext-int.cpp | 4 +++- 5 files changed, 6 insertions(+), 29 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a541d399d1e749..28a4dfb523f44e 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -414,6 +414,8 @@ Non-comprehensive list of changes in this release ``__builtin_elementwise_bitreverse``, ``__builtin_elementwise_add_sat``, ``__builtin_elementwise_sub_sat``. +- Clang now rejects ``_Complex _BitInt`` types. + New Compiler Flags ------------------ diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index ee237ffc4d2b99..47644680b720bf 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -1343,8 +1343,7 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) { S.getLocForEndOfToken(getTypeSpecComplexLoc()), " double"); TypeSpecType = TST_double; // _Complex -> _Complex double. - } else if (TypeSpecType == TST_int || TypeSpecType == TST_char || - TypeSpecType == TST_bitint) { + } else if (TypeSpecType == TST_int || TypeSpecType == TST_char) { // Note that this intentionally doesn't include _Complex _Bool. if (!S.getLangOpts().CPlusPlus) S.Diag(TSTLoc, diag::ext_integer_complex); diff --git a/clang/test/AST/ByteCode/complex.cpp b/clang/test/AST/ByteCode/complex.cpp index ee11c6214b70c5..2c0111c53d3bfe 100644 --- a/clang/test/AST/ByteCode/complex.cpp +++ b/clang/test/AST/ByteCode/complex.cpp @@ -146,11 +146,6 @@ constexpr _Complex int I3 = {15}; static_assert(__real(I3) == 15, ""); static_assert(__imag(I3) == 0, ""); -constexpr _Complex _BitInt(8) A = {4}; -static_assert(__real(A) == 4, ""); -static_assert(__imag(A) == 0, ""); - - constexpr _Complex double Doubles[4] = {{1.0, 2.0}}; static_assert(__real(Doubles[0]) == 1.0, ""); static_assert(__imag(Doubles[0]) == 2.0, ""); @@ -163,9 +158,6 @@ static_assert(__imag(Doubles[3]) == 0.0, ""); static_assert(~(0.5 + 1.5j) == (0.5 + -1.5j), ""); -static_assert(__extension__ __imag(A) == 0, ""); -static_assert(__imag(__extension__ A) == 0, ""); - void func(void) { __complex__ int arr; _Complex int result; diff --git a/clang/test/CodeGenCXX/ext-int.cpp b/clang/test/CodeGenCXX/ext-int.cpp index 97b5d6ce16b880..f470398ec2095d 100644 --- a/clang/test/CodeGenCXX/ext-int.cpp +++ b/clang/test/CodeGenCXX/ext-int.cpp @@ -549,24 +549,6 @@ void Shift(_BitInt(28) Ext, _BitInt(65) LargeExt, int i) { // CHECK: ashr i65 {{.+}}, %[[PROMO]] } -void ComplexTest(_Complex _BitInt(12) first, _Complex _BitInt(33) second) { - // LIN: define{{.*}} void @_Z11ComplexTestCDB12_CDB33_ - // WIN: define dso_local void @"?ComplexTest@@YAXU?$_Complex@U?$_BitInt@$0M@@__clang@@@__clang@@U?$_Complex@U?$_BitInt@$0CB@@__clang@@@2@@Z" - first + second; - // CHECK: %[[FIRST_REALP:.+]] = getelementptr inbounds nuw { i12, i12 }, ptr %{{.+}}, i32 0, i32 0 - // CHECK: %[[FIRST_REAL:.+]] = load i12, ptr %[[FIRST_REALP]] - // CHECK: %[[FIRST_IMAGP:.+]] = getelementptr inbounds nuw { i12, i12 }, ptr %{{.+}}, i32 0, i32 1 - // CHECK: %[[FIRST_IMAG:.+]] = load i12, ptr %[[FIRST_IMAGP]] - // CHECK: %[[FIRST_REAL_CONV:.+]] = sext i12 %[[FIRST_REAL]] - // CHECK: %[[FIRST_IMAG_CONV:.+]] = sext i12 %[[FIRST_IMAG]] - // CHECK: %[[SECOND_REALP:.+]] = getelementptr inbounds nuw { i33, i33 }, ptr %{{.+}}, i32 0, i32 0 - // CHECK: %[[SECOND_REAL:.+]] = load i33, ptr %[[SECOND_REALP]] - // CHECK: %[[SECOND_IMAGP:.+]] = getelementptr inbounds nuw { i33, i33 }, ptr %{{.+}}, i32 0, i32 1 - // CHECK: %[[SECOND_IMAG:.+]] = load i33, ptr %[[SECOND_IMAGP]] - // CHECK: %[[REAL:.+]] = add i33 %[[FIRST_REAL_CONV]], %[[SECOND_REAL]] - // CHECK: %[[IMAG:.+]] = add i33 %[[FIRST_IMAG_CONV]], %[[SECOND_IMAG]] -} - typedef _BitInt(64) vint64_t16 __attribute__((vector_size(16))); void VectorTest(vint64_t16 first, vint64_t16 second) { // LIN: define{{.*}} void @_Z10VectorTestDv2_DB64_S0_(<2 x i64> %{{.+}}, <2 x i64> %{{.+}}) diff --git a/clang/test/SemaCXX/ext-int.cpp b/clang/test/SemaCXX/ext-int.cpp index 000b871ccd3433..d974221e774a79 100644 --- a/clang/test/SemaCXX/ext-int.cpp +++ b/clang/test/SemaCXX/ext-int.cpp @@ -101,8 +101,10 @@ typedef _BitInt(37) __attribute__((vector_size(16))) VecTy4; // expected-error@+1{{'_BitInt' vector element width must be a power of 2}} typedef _BitInt(37) __attribute__((ext_vector_type(32))) OtherVecTy4; -// Allow _Complex: +// expected-error@+1{{'_Complex _BitInt' is invalid}} _Complex _BitInt(3) Cmplx; +// expected-error@+1{{'_Complex _BitInt' is invalid}} +typedef _Complex _BitInt(3) Cmp; // Reject cases of _Atomic: // expected-error@+1{{_Atomic cannot be applied to integer type '_BitInt(4)'}} >From 67c092d34359ec92e006f4a315be6725a5b39f48 Mon Sep 17 00:00:00 2001 From: "Podchishchaeva, Mariya" <mariya.podchishcha...@intel.com> Date: Tue, 10 Dec 2024 07:58:45 -0800 Subject: [PATCH 2/2] Move release note to breaking changes --- clang/docs/ReleaseNotes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 28a4dfb523f44e..e74fb4a60d3b63 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -61,6 +61,8 @@ code bases. C/C++ Language Potentially Breaking Changes ------------------------------------------- +- Clang now rejects ``_Complex _BitInt`` types. + C++ Specific Potentially Breaking Changes ----------------------------------------- @@ -414,8 +416,6 @@ Non-comprehensive list of changes in this release ``__builtin_elementwise_bitreverse``, ``__builtin_elementwise_add_sat``, ``__builtin_elementwise_sub_sat``. -- Clang now rejects ``_Complex _BitInt`` types. - New Compiler Flags ------------------ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits