diff options
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/AST/ast-dump-stmt.c | 2 | ||||
| -rw-r--r-- | clang/test/CodeGen/X86/avx512bw-builtins.c | 140 | ||||
| -rw-r--r-- | clang/test/CodeGen/X86/avx512dq-builtins.c | 108 | ||||
| -rw-r--r-- | clang/test/CodeGen/X86/avx512f-builtins.c | 40 | ||||
| -rw-r--r-- | clang/test/CodeGen/attr-counted-by-void-ptr-gnu.c | 65 | ||||
| -rw-r--r-- | clang/test/CodeGen/exprs.c | 9 | ||||
| -rw-r--r-- | clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c | 6 | ||||
| -rw-r--r-- | clang/test/Sema/attr-counted-by-or-null-last-field.c | 8 | ||||
| -rw-r--r-- | clang/test/Sema/attr-counted-by-or-null-late-parsed-struct-ptrs.c | 6 | ||||
| -rw-r--r-- | clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c | 10 | ||||
| -rw-r--r-- | clang/test/Sema/attr-counted-by-struct-ptrs.c | 10 | ||||
| -rw-r--r-- | clang/test/Sema/attr-counted-by-void-ptr-gnu.c | 101 | ||||
| -rw-r--r-- | clang/test/Sema/statements.c | 9 | ||||
| -rw-r--r-- | clang/test/SemaCUDA/error-includes-mode.cu | 9 | ||||
| -rw-r--r-- | clang/test/SemaCXX/cxx2b-consteval-propagate.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/statements.cpp | 17 |
16 files changed, 519 insertions, 23 deletions
diff --git a/clang/test/AST/ast-dump-stmt.c b/clang/test/AST/ast-dump-stmt.c index 5c44fea..6fb01a4 100644 --- a/clang/test/AST/ast-dump-stmt.c +++ b/clang/test/AST/ast-dump-stmt.c @@ -400,7 +400,7 @@ void TestMiscStmts(void) { // CHECK-NEXT: ImplicitCastExpr // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:17> 'int' lvalue Var 0x{{[^ ]*}} 'a' 'int' ({int a = 10; a;;; }); - // CHECK-NEXT: StmtExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:23> 'int' + // CHECK-NEXT: StmtExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:23> 'void' // CHECK-NEXT: CompoundStmt // CHECK-NEXT: DeclStmt // CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:5, col:13> col:9 used a 'int' cinit diff --git a/clang/test/CodeGen/X86/avx512bw-builtins.c b/clang/test/CodeGen/X86/avx512bw-builtins.c index e6e2e38..834e140 100644 --- a/clang/test/CodeGen/X86/avx512bw-builtins.c +++ b/clang/test/CodeGen/X86/avx512bw-builtins.c @@ -209,6 +209,10 @@ unsigned char test_kortestz_mask32_u8(__m512i __A, __m512i __B, __m512i __C, __m _mm512_cmpneq_epu16_mask(__C, __D)); } +TEST_CONSTEXPR(_kortestz_mask32_u8(0x0000'0000, 0x0000'0000) == 1); +TEST_CONSTEXPR(_kortestz_mask32_u8(0x0000'0000, 0x8000'0000) == 0); +TEST_CONSTEXPR(_kortestz_mask32_u8(0x0123'4567, 0xFEDC'BA98) == 0); + unsigned char test_kortestc_mask32_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_kortestc_mask32_u8 // CHECK: [[LHS:%.*]] = bitcast i32 %{{.*}} to <32 x i1> @@ -222,6 +226,10 @@ unsigned char test_kortestc_mask32_u8(__m512i __A, __m512i __B, __m512i __C, __m _mm512_cmpneq_epu16_mask(__C, __D)); } +TEST_CONSTEXPR(_kortestc_mask32_u8(0x0000'0000, 0x0000'0000) == 0); +TEST_CONSTEXPR(_kortestc_mask32_u8(0x0000'0000, 0x8000'0000) == 0); +TEST_CONSTEXPR(_kortestc_mask32_u8(0x0123'4567, 0xFEDC'BA98) == 1); + unsigned char test_kortest_mask32_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D, unsigned char *CF) { // CHECK-LABEL: test_kortest_mask32_u8 // CHECK: [[LHS:%.*]] = bitcast i32 %{{.*}} to <32 x i1> @@ -242,6 +250,30 @@ unsigned char test_kortest_mask32_u8(__m512i __A, __m512i __B, __m512i __C, __m5 _mm512_cmpneq_epu16_mask(__C, __D), CF); } +// Test constexpr handling. +#if defined(__cplusplus) && (__cplusplus >= 201103L) +constexpr unsigned char +test_kortest_mask32_u8(unsigned int A, unsigned int B) { + unsigned char all_ones{}; + return (_kortest_mask32_u8(A, B, &all_ones) << 4) | all_ones; +} + +void _kortest_mask32_u8() { + constexpr unsigned int A1 = 0x0000'0000; + constexpr unsigned int B1 = 0x0000'0000; + constexpr unsigned char expected_result_1 = 0x10; + static_assert(test_kortest_mask32_u8(A1, B1) == expected_result_1); + constexpr unsigned int A2 = 0x0000'0000; + constexpr unsigned int B2 = 0x8000'0000; + constexpr unsigned char expected_result_2 = 0x00; + static_assert(test_kortest_mask32_u8(A2, B2) == expected_result_2); + constexpr unsigned int A3 = 0x0123'4567; + constexpr unsigned int B3 = 0xFEDC'BA98; + constexpr unsigned char expected_result_3 = 0x01; + static_assert(test_kortest_mask32_u8(A3, B3) == expected_result_3); +} +#endif + unsigned char test_kortestz_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_kortestz_mask64_u8 // CHECK: [[LHS:%.*]] = bitcast i64 %{{.*}} to <64 x i1> @@ -255,6 +287,10 @@ unsigned char test_kortestz_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m _mm512_cmpneq_epu8_mask(__C, __D)); } +TEST_CONSTEXPR(_kortestz_mask64_u8(0x0000'0000'0000'0000, 0x0000'0000'0000'0000) == 1); +TEST_CONSTEXPR(_kortestz_mask64_u8(0x0000'0000'0000'0000, 0x8000'0000'0000'0000) == 0); +TEST_CONSTEXPR(_kortestz_mask64_u8(0x0123'4567'89AB'CDEF, 0xFEDC'BA98'7654'3210) == 0); + unsigned char test_kortestc_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_kortestc_mask64_u8 // CHECK: [[LHS:%.*]] = bitcast i64 %{{.*}} to <64 x i1> @@ -268,6 +304,10 @@ unsigned char test_kortestc_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m _mm512_cmpneq_epu8_mask(__C, __D)); } +TEST_CONSTEXPR(_kortestc_mask64_u8(0x0000'0000'0000'0000, 0x0000'0000'0000'0000) == 0); +TEST_CONSTEXPR(_kortestc_mask64_u8(0x0023'4567'89AB'CDEF, 0xFEDC'BA98'7654'3210) == 0); +TEST_CONSTEXPR(_kortestc_mask64_u8(0x0123'4567'89AB'CDEF, 0xFEDC'BA98'7654'3210) == 1); + unsigned char test_kortest_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D, unsigned char *CF) { // CHECK-LABEL: test_kortest_mask64_u8 // CHECK: [[LHS:%.*]] = bitcast i64 %{{.*}} to <64 x i1> @@ -288,6 +328,30 @@ unsigned char test_kortest_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m5 _mm512_cmpneq_epu8_mask(__C, __D), CF); } +// Test constexpr handling. +#if defined(__cplusplus) && (__cplusplus >= 201103L) +constexpr unsigned char +test_kortest_mask64_u8(unsigned long long A, unsigned long long B) { + unsigned char all_ones{}; + return (_kortest_mask64_u8(A, B, &all_ones) << 4) | all_ones; +} + +void _kortest_mask64_u8() { + constexpr unsigned long long A1 = 0x0000'0000'0000'0000; + constexpr unsigned long long B1 = 0x0000'0000'0000'0000; + constexpr unsigned char expected_result_1 = 0x10; + static_assert(test_kortest_mask64_u8(A1, B1) == expected_result_1); + constexpr unsigned long long A2 = 0x0000'0000'0000'0000; + constexpr unsigned long long B2 = 0x8000'0000'0000'0000; + constexpr unsigned char expected_result_2 = 0x00; + static_assert(test_kortest_mask64_u8(A2, B2) == expected_result_2); + constexpr unsigned long long A3 = 0x0123'4567'89AB'CDEF; + constexpr unsigned long long B3 = 0xFEDC'BA98'7654'3210; + constexpr unsigned char expected_result_3 = 0x01; + static_assert(test_kortest_mask64_u8(A3, B3) == expected_result_3); +} +#endif + unsigned char test_ktestz_mask32_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_ktestz_mask32_u8 // CHECK: [[LHS:%.*]] = bitcast i32 %{{.*}} to <32 x i1> @@ -298,6 +362,11 @@ unsigned char test_ktestz_mask32_u8(__m512i __A, __m512i __B, __m512i __C, __m51 _mm512_cmpneq_epu16_mask(__C, __D)); } +TEST_CONSTEXPR(_ktestz_mask32_u8(0x0000'0000, 0x0000'0000) == 1); +TEST_CONSTEXPR(_ktestz_mask32_u8(0x0000'0000, 0x8000'0000) == 1); +TEST_CONSTEXPR(_ktestz_mask32_u8(0xF000'0000, 0x8000'0000) == 0); +TEST_CONSTEXPR(_ktestz_mask32_u8(0x0123'4567, 0x0123'4567) == 0); + unsigned char test_ktestc_mask32_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_ktestc_mask32_u8 // CHECK: [[LHS:%.*]] = bitcast i32 %{{.*}} to <32 x i1> @@ -308,6 +377,11 @@ unsigned char test_ktestc_mask32_u8(__m512i __A, __m512i __B, __m512i __C, __m51 _mm512_cmpneq_epu16_mask(__C, __D)); } +TEST_CONSTEXPR(_ktestc_mask32_u8(0x0000'0000, 0x0000'0000) == 1); +TEST_CONSTEXPR(_ktestc_mask32_u8(0x0000'0000, 0x8000'0000) == 0); +TEST_CONSTEXPR(_ktestc_mask32_u8(0xF000'0000, 0x8000'0000) == 1); +TEST_CONSTEXPR(_ktestc_mask32_u8(0x0123'4567, 0x0123'4567) == 1); + unsigned char test_ktest_mask32_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D, unsigned char *CF) { // CHECK-LABEL: test_ktest_mask32_u8 // CHECK: [[LHS:%.*]] = bitcast i32 %{{.*}} to <32 x i1> @@ -322,6 +396,34 @@ unsigned char test_ktest_mask32_u8(__m512i __A, __m512i __B, __m512i __C, __m512 _mm512_cmpneq_epu16_mask(__C, __D), CF); } +// Test constexpr handling. +#if defined(__cplusplus) && (__cplusplus >= 201103L) +constexpr unsigned char +test_ktest_mask32_u8(unsigned int A, unsigned int B) { + unsigned char and_not{}; + return (_ktest_mask32_u8(A, B, &and_not) << 4) | and_not; +} + +void _ktest_mask32_u8() { + constexpr unsigned int A1 = 0x0000'0000; + constexpr unsigned int B1 = 0x0000'0000; + constexpr unsigned char expected_result_1 = 0x11; + static_assert(test_ktest_mask32_u8(A1, B1) == expected_result_1); + constexpr unsigned int A2 = 0x0000'0000; + constexpr unsigned int B2 = 0x8000'0000; + constexpr unsigned char expected_result_2 = 0x10; + static_assert(test_ktest_mask32_u8(A2, B2) == expected_result_2); + constexpr unsigned int A3 = 0xF000'0000; + constexpr unsigned int B3 = 0x8000'0000; + constexpr unsigned char expected_result_3 = 0x01; + static_assert(test_ktest_mask32_u8(A3, B3) == expected_result_3); + constexpr unsigned int A4 = 0x0123'4567; + constexpr unsigned int B4 = 0x0123'4567; + constexpr unsigned char expected_result_4 = 0x01; + static_assert(test_ktest_mask32_u8(A4, B4) == expected_result_4); +} +#endif + unsigned char test_ktestz_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_ktestz_mask64_u8 // CHECK: [[LHS:%.*]] = bitcast i64 %{{.*}} to <64 x i1> @@ -332,6 +434,11 @@ unsigned char test_ktestz_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m51 _mm512_cmpneq_epu8_mask(__C, __D)); } +TEST_CONSTEXPR(_ktestz_mask64_u8(0x0000'0000'0000'0000, 0x0000'0000'0000'0000) == 1); +TEST_CONSTEXPR(_ktestz_mask64_u8(0x0000'0000'0000'0000, 0x8000'0000'0000'0000) == 1); +TEST_CONSTEXPR(_ktestz_mask64_u8(0xF000'0000'0000'0000, 0x8000'0000'0000'0000) == 0); +TEST_CONSTEXPR(_ktestz_mask64_u8(0x0123'4567'89AB'CDEF, 0x0123'4567'89AB'CDEF) == 0); + unsigned char test_ktestc_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_ktestc_mask64_u8 // CHECK: [[LHS:%.*]] = bitcast i64 %{{.*}} to <64 x i1> @@ -342,6 +449,11 @@ unsigned char test_ktestc_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m51 _mm512_cmpneq_epu8_mask(__C, __D)); } +TEST_CONSTEXPR(_ktestc_mask64_u8(0x0000'0000'0000'0000, 0x0000'0000'0000'0000) == 1); +TEST_CONSTEXPR(_ktestc_mask64_u8(0x0000'0000'0000'0000, 0x8000'0000'0000'0000) == 0); +TEST_CONSTEXPR(_ktestc_mask64_u8(0xF000'0000'0000'0000, 0x8000'0000'0000'0000) == 1); +TEST_CONSTEXPR(_ktestc_mask64_u8(0x0123'4567'89AB'CDEF, 0x0123'4567'89AB'CDEF) == 1); + unsigned char test_ktest_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D, unsigned char *CF) { // CHECK-LABEL: test_ktest_mask64_u8 // CHECK: [[LHS:%.*]] = bitcast i64 %{{.*}} to <64 x i1> @@ -356,6 +468,34 @@ unsigned char test_ktest_mask64_u8(__m512i __A, __m512i __B, __m512i __C, __m512 _mm512_cmpneq_epu8_mask(__C, __D), CF); } +// Test constexpr handling. +#if defined(__cplusplus) && (__cplusplus >= 201402L) +constexpr unsigned char +test_ktest_mask64_u8(unsigned long long A, unsigned long long B) { + unsigned char and_not{}; + return (_ktest_mask64_u8(A, B, &and_not) << 4) | and_not; +} + +void _ktest_mask64_u8() { + constexpr unsigned long long A1 = 0x0000'0000'0000'0000; + constexpr unsigned long long B1 = 0x0000'0000'0000'0000; + constexpr unsigned char expected_result_1 = 0x11; + static_assert(test_ktest_mask64_u8(A1, B1) == expected_result_1); + constexpr unsigned long long A2 = 0x0000'0000'0000'0000; + constexpr unsigned long long B2 = 0x8000'0000'0000'0000; + constexpr unsigned char expected_result_2 = 0x10; + static_assert(test_ktest_mask64_u8(A2, B2) == expected_result_2); + constexpr unsigned long long A3 = 0xF000'0000'0000'0000; + constexpr unsigned long long B3 = 0x8000'0000'0000'0000; + constexpr unsigned char expected_result_3 = 0x01; + static_assert(test_ktest_mask64_u8(A3, B3) == expected_result_3); + constexpr unsigned long long A4 = 0x0123'4567'89AB'CDEF; + constexpr unsigned long long B4 = 0x0123'4567'89AB'CDEF; + constexpr unsigned char expected_result_4 = 0x01; + static_assert(test_ktest_mask64_u8(A4, B4) == expected_result_4); +} +#endif + __mmask32 test_kadd_mask32(__m512i __A, __m512i __B, __m512i __C, __m512i __D, __m512i __E, __m512i __F) { // CHECK-LABEL: test_kadd_mask32 // CHECK: [[LHS:%.*]] = bitcast i32 %{{.*}} to <32 x i1> diff --git a/clang/test/CodeGen/X86/avx512dq-builtins.c b/clang/test/CodeGen/X86/avx512dq-builtins.c index 9c4ada3..efe983c 100644 --- a/clang/test/CodeGen/X86/avx512dq-builtins.c +++ b/clang/test/CodeGen/X86/avx512dq-builtins.c @@ -117,6 +117,10 @@ unsigned char test_kortestz_mask8_u8(__m512i __A, __m512i __B, __m512i __C, __m5 _mm512_cmpneq_epu64_mask(__C, __D)); } +TEST_CONSTEXPR(_kortestz_mask8_u8(0x00, 0x00) == 1); +TEST_CONSTEXPR(_kortestz_mask8_u8(0x00, 0x80) == 0); +TEST_CONSTEXPR(_kortestz_mask8_u8(0x01, 0xFE) == 0); + unsigned char test_kortestc_mask8_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_kortestc_mask8_u8 // CHECK: [[LHS:%.*]] = bitcast i8 %{{.*}} to <8 x i1> @@ -130,6 +134,10 @@ unsigned char test_kortestc_mask8_u8(__m512i __A, __m512i __B, __m512i __C, __m5 _mm512_cmpneq_epu64_mask(__C, __D)); } +TEST_CONSTEXPR(_kortestc_mask8_u8(0x00, 0x00) == 0); +TEST_CONSTEXPR(_kortestc_mask8_u8(0x00, 0x80) == 0); +TEST_CONSTEXPR(_kortestc_mask8_u8(0x01, 0xFE) == 1); + unsigned char test_kortest_mask8_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D, unsigned char *CF) { // CHECK-LABEL: test_kortest_mask8_u8 // CHECK: [[LHS:%.*]] = bitcast i8 %{{.*}} to <8 x i1> @@ -150,6 +158,30 @@ unsigned char test_kortest_mask8_u8(__m512i __A, __m512i __B, __m512i __C, __m51 _mm512_cmpneq_epu64_mask(__C, __D), CF); } +// Test constexpr handling. +#if defined(__cplusplus) && (__cplusplus >= 201103L) +constexpr unsigned char +test_kortest_mask8_u8(unsigned char A, unsigned char B) { + unsigned char all_ones{}; + return (_kortest_mask8_u8(A, B, &all_ones) << 4) | all_ones; +} + +void _kortest_mask8_u8() { + constexpr unsigned char A1 = 0x00; + constexpr unsigned char B1 = 0x00; + constexpr unsigned char expected_result_1 = 0x10; + static_assert(test_kortest_mask8_u8(A1, B1) == expected_result_1); + constexpr unsigned char A2 = 0x00; + constexpr unsigned char B2 = 0x80; + constexpr unsigned char expected_result_2 = 0x00; + static_assert(test_kortest_mask8_u8(A2, B2) == expected_result_2); + constexpr unsigned char A3 = 0x01; + constexpr unsigned char B3 = 0xFE; + constexpr unsigned char expected_result_3 = 0x01; + static_assert(test_kortest_mask8_u8(A3, B3) == expected_result_3); +} +#endif + unsigned char test_ktestz_mask8_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_ktestz_mask8_u8 // CHECK: [[LHS:%.*]] = bitcast i8 %{{.*}} to <8 x i1> @@ -160,6 +192,11 @@ unsigned char test_ktestz_mask8_u8(__m512i __A, __m512i __B, __m512i __C, __m512 _mm512_cmpneq_epu64_mask(__C, __D)); } +TEST_CONSTEXPR(_ktestz_mask8_u8(0x00, 0x00) == 1); +TEST_CONSTEXPR(_ktestz_mask8_u8(0x00, 0x80) == 1); +TEST_CONSTEXPR(_ktestz_mask8_u8(0xF0, 0x80) == 0); +TEST_CONSTEXPR(_ktestz_mask8_u8(0x01, 0x01) == 0); + unsigned char test_ktestc_mask8_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_ktestc_mask8_u8 // CHECK: [[LHS:%.*]] = bitcast i8 %{{.*}} to <8 x i1> @@ -170,6 +207,11 @@ unsigned char test_ktestc_mask8_u8(__m512i __A, __m512i __B, __m512i __C, __m512 _mm512_cmpneq_epu64_mask(__C, __D)); } +TEST_CONSTEXPR(_ktestc_mask8_u8(0x00, 0x00) == 1); +TEST_CONSTEXPR(_ktestc_mask8_u8(0x00, 0x80) == 0); +TEST_CONSTEXPR(_ktestc_mask8_u8(0xF0, 0x80) == 1); +TEST_CONSTEXPR(_ktestc_mask8_u8(0x01, 0x01) == 1); + unsigned char test_ktest_mask8_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D, unsigned char *CF) { // CHECK-LABEL: test_ktest_mask8_u8 // CHECK: [[LHS:%.*]] = bitcast i8 %{{.*}} to <8 x i1> @@ -184,6 +226,34 @@ unsigned char test_ktest_mask8_u8(__m512i __A, __m512i __B, __m512i __C, __m512i _mm512_cmpneq_epu64_mask(__C, __D), CF); } +// Test constexpr handling. +#if defined(__cplusplus) && (__cplusplus >= 201103L) +constexpr unsigned char +test_ktest_mask8_u8(unsigned char A, unsigned char B) { + unsigned char all_ones{}; + return (_ktest_mask8_u8(A, B, &all_ones) << 4) | all_ones; +} + +void _ktest_mask8_u8() { + constexpr unsigned char A1 = 0x00; + constexpr unsigned char B1 = 0x00; + constexpr unsigned char expected_result_1 = 0x11; + static_assert(test_ktest_mask8_u8(A1, B1) == expected_result_1); + constexpr unsigned char A2 = 0x00; + constexpr unsigned char B2 = 0x80; + constexpr unsigned char expected_result_2 = 0x10; + static_assert(test_ktest_mask8_u8(A2, B2) == expected_result_2); + constexpr unsigned char A3 = 0xF0; + constexpr unsigned char B3 = 0x80; + constexpr unsigned char expected_result_3 = 0x01; + static_assert(test_ktest_mask8_u8(A3, B3) == expected_result_3); + constexpr unsigned char A4 = 0x01; + constexpr unsigned char B4 = 0x01; + constexpr unsigned char expected_result_4 = 0x01; + static_assert(test_ktest_mask8_u8(A4, B4) == expected_result_4); +} +#endif + unsigned char test_ktestz_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_ktestz_mask16_u8 // CHECK: [[LHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> @@ -194,6 +264,11 @@ unsigned char test_ktestz_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m51 _mm512_cmpneq_epu32_mask(__C, __D)); } +TEST_CONSTEXPR(_ktestz_mask16_u8(0x0000, 0x0000) == 1); +TEST_CONSTEXPR(_ktestz_mask16_u8(0x0000, 0x8000) == 1); +TEST_CONSTEXPR(_ktestz_mask16_u8(0xF000, 0x8000) == 0); +TEST_CONSTEXPR(_ktestz_mask16_u8(0x0123, 0x0123) == 0); + unsigned char test_ktestc_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_ktestc_mask16_u8 // CHECK: [[LHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> @@ -204,6 +279,11 @@ unsigned char test_ktestc_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m51 _mm512_cmpneq_epu32_mask(__C, __D)); } +TEST_CONSTEXPR(_ktestc_mask16_u8(0x0000, 0x0000) == 1); +TEST_CONSTEXPR(_ktestc_mask16_u8(0x0000, 0x8000) == 0); +TEST_CONSTEXPR(_ktestc_mask16_u8(0xF000, 0x8000) == 1); +TEST_CONSTEXPR(_ktestc_mask16_u8(0x0123, 0x0123) == 1); + unsigned char test_ktest_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D, unsigned char *CF) { // CHECK-LABEL: test_ktest_mask16_u8 // CHECK: [[LHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> @@ -218,6 +298,34 @@ unsigned char test_ktest_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m512 _mm512_cmpneq_epu32_mask(__C, __D), CF); } +// Test constexpr handling. +#if defined(__cplusplus) && (__cplusplus >= 201103L) +constexpr unsigned char +test_ktest_mask16_u8(unsigned int A, unsigned int B) { + unsigned char all_ones{}; + return (_ktest_mask16_u8(A, B, &all_ones) << 4) | all_ones; +} + +void _ktest_mask16_u8() { + constexpr unsigned int A1 = 0x0000; + constexpr unsigned int B1 = 0x0000; + constexpr unsigned char expected_result_1 = 0x11; + static_assert(test_ktest_mask16_u8(A1, B1) == expected_result_1); + constexpr unsigned int A2 = 0x0000; + constexpr unsigned int B2 = 0x8000; + constexpr unsigned char expected_result_2 = 0x10; + static_assert(test_ktest_mask16_u8(A2, B2) == expected_result_2); + constexpr unsigned int A3 = 0xF000; + constexpr unsigned int B3 = 0x8000; + constexpr unsigned char expected_result_3 = 0x01; + static_assert(test_ktest_mask16_u8(A3, B3) == expected_result_3); + constexpr unsigned int A4 = 0x0123; + constexpr unsigned int B4 = 0x0123; + constexpr unsigned char expected_result_4 = 0x01; + static_assert(test_ktest_mask16_u8(A4, B4) == expected_result_4); +} +#endif + __mmask8 test_kadd_mask8(__m512i __A, __m512i __B, __m512i __C, __m512i __D, __m512i __E, __m512i __F) { // CHECK-LABEL: test_kadd_mask8 // CHECK: [[LHS:%.*]] = bitcast i8 %{{.*}} to <8 x i1> diff --git a/clang/test/CodeGen/X86/avx512f-builtins.c b/clang/test/CodeGen/X86/avx512f-builtins.c index 8e65430..17778b52 100644 --- a/clang/test/CodeGen/X86/avx512f-builtins.c +++ b/clang/test/CodeGen/X86/avx512f-builtins.c @@ -9015,6 +9015,10 @@ int test_mm512_kortestc(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { _mm512_cmpneq_epu32_mask(__C, __D)); } +TEST_CONSTEXPR(_mm512_kortestc(0x0000, 0x0000) == 0); +TEST_CONSTEXPR(_mm512_kortestc(0x0000, 0x8000) == 0); +TEST_CONSTEXPR(_mm512_kortestc(0x0123, 0xFEDC) == 1); + int test_mm512_kortestz(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_mm512_kortestz // CHECK: [[LHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> @@ -9027,6 +9031,10 @@ int test_mm512_kortestz(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { _mm512_cmpneq_epu32_mask(__C, __D)); } +TEST_CONSTEXPR(_mm512_kortestz(0x0000, 0x0000) == 1); +TEST_CONSTEXPR(_mm512_kortestz(0x0000, 0x8000) == 0); +TEST_CONSTEXPR(_mm512_kortestz(0x0123, 0xFEDC) == 0); + unsigned char test_kortestz_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_kortestz_mask16_u8 // CHECK: [[LHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> @@ -9040,6 +9048,10 @@ unsigned char test_kortestz_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m _mm512_cmpneq_epu32_mask(__C, __D)); } +TEST_CONSTEXPR(_kortestz_mask16_u8(0x0000, 0x0000) == 1); +TEST_CONSTEXPR(_kortestz_mask16_u8(0x0000, 0x8000) == 0); +TEST_CONSTEXPR(_kortestz_mask16_u8(0x0123, 0xFEDC) == 0); + unsigned char test_kortestc_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: test_kortestc_mask16_u8 // CHECK: [[LHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> @@ -9053,6 +9065,10 @@ unsigned char test_kortestc_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m _mm512_cmpneq_epu32_mask(__C, __D)); } +TEST_CONSTEXPR(_kortestc_mask16_u8(0x0000, 0x0000) == 0); +TEST_CONSTEXPR(_kortestc_mask16_u8(0x0000, 0x8000) == 0); +TEST_CONSTEXPR(_kortestc_mask16_u8(0x0123, 0xFEDC) == 1); + unsigned char test_kortest_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m512i __D, unsigned char *CF) { // CHECK-LABEL: test_kortest_mask16_u8 // CHECK: [[LHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> @@ -9073,6 +9089,30 @@ unsigned char test_kortest_mask16_u8(__m512i __A, __m512i __B, __m512i __C, __m5 _mm512_cmpneq_epu32_mask(__C, __D), CF); } +// Test constexpr handling. +#if defined(__cplusplus) && (__cplusplus >= 201103L) +constexpr unsigned char +test_kortest_mask16_u8(unsigned short A, unsigned short B) { + unsigned char all_ones{}; + return (_kortest_mask16_u8(A, B, &all_ones) << 4) | all_ones; +} + +void _kortest_mask16_u8() { + constexpr unsigned short A1 = 0x0000; + constexpr unsigned short B1 = 0x0000; + constexpr unsigned char expected_result_1 = 0x10; + static_assert(test_kortest_mask16_u8(A1, B1) == expected_result_1); + constexpr unsigned short A2 = 0x0000; + constexpr unsigned short B2 = 0x8000; + constexpr unsigned char expected_result_2 = 0x00; + static_assert(test_kortest_mask16_u8(A2, B2) == expected_result_2); + constexpr unsigned short A3 = 0x0123; + constexpr unsigned short B3 = 0xFEDC; + constexpr unsigned char expected_result_3 = 0x01; + static_assert(test_kortest_mask16_u8(A3, B3) == expected_result_3); +} +#endif + __mmask16 test_mm512_kunpackb(__m512i __A, __m512i __B, __m512i __C, __m512i __D, __m512i __E, __m512i __F) { // CHECK-LABEL: test_mm512_kunpackb // CHECK: [[LHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> diff --git a/clang/test/CodeGen/attr-counted-by-void-ptr-gnu.c b/clang/test/CodeGen/attr-counted-by-void-ptr-gnu.c new file mode 100644 index 0000000..e22aad3 --- /dev/null +++ b/clang/test/CodeGen/attr-counted-by-void-ptr-gnu.c @@ -0,0 +1,65 @@ +// RUN: %clang_cc1 -std=gnu11 -triple x86_64-unknown-linux-gnu -O2 -emit-llvm -o - %s | FileCheck %s + +// Test that counted_by on void* in GNU mode treats void as having size 1 (byte count) + +#define __counted_by(f) __attribute__((counted_by(f))) +#define __sized_by(f) __attribute__((sized_by(f))) + +struct with_counted_by_void { + int count; + void* buf __counted_by(count); +}; + +struct with_sized_by_void { + int size; + void* buf __sized_by(size); +}; + +struct with_counted_by_int { + int count; + int* buf __counted_by(count); +}; + +// CHECK-LABEL: define dso_local {{.*}}@test_counted_by_void( +// CHECK: %[[COUNT:.*]] = load i32, ptr %s +// CHECK: %[[NARROW:.*]] = tail call i32 @llvm.smax.i32(i32 %[[COUNT]], i32 0) +// CHECK: %[[ZEXT:.*]] = zext nneg i32 %[[NARROW]] to i64 +// CHECK: ret i64 %[[ZEXT]] +// +// Verify: counted_by on void* returns the count directly (count * 1 byte) +long long test_counted_by_void(struct with_counted_by_void *s) { + return __builtin_dynamic_object_size(s->buf, 0); +} + +// CHECK-LABEL: define dso_local {{.*}}@test_sized_by_void( +// CHECK: %[[SIZE:.*]] = load i32, ptr %s +// CHECK: %[[NARROW:.*]] = tail call i32 @llvm.smax.i32(i32 %[[SIZE]], i32 0) +// CHECK: %[[ZEXT:.*]] = zext nneg i32 %[[NARROW]] to i64 +// CHECK: ret i64 %[[ZEXT]] +// +// Verify: sized_by on void* returns the size directly +long long test_sized_by_void(struct with_sized_by_void *s) { + return __builtin_dynamic_object_size(s->buf, 0); +} + +// CHECK-LABEL: define dso_local {{.*}}@test_counted_by_int( +// CHECK: %[[COUNT:.*]] = load i32, ptr %s +// CHECK: %[[SEXT:.*]] = sext i32 %[[COUNT]] to i64 +// CHECK: %[[SIZE:.*]] = shl nsw i64 %[[SEXT]], 2 +// CHECK: ret i64 +// +// Verify: counted_by on int* returns count * sizeof(int) = count * 4 +long long test_counted_by_int(struct with_counted_by_int *s) { + return __builtin_dynamic_object_size(s->buf, 0); +} + +// CHECK-LABEL: define dso_local ptr @test_void_ptr_arithmetic( +// CHECK: %[[BUF:.*]] = load ptr, ptr +// CHECK: %[[EXT:.*]] = sext i32 %offset to i64 +// CHECK: %[[PTR:.*]] = getelementptr inbounds i8, ptr %[[BUF]], i64 %[[EXT]] +// CHECK: ret ptr %[[PTR]] +// +// Verify: pointer arithmetic on void* uses i8 (byte offsets), not i32 or other sizes +void* test_void_ptr_arithmetic(struct with_counted_by_void *s, int offset) { + return s->buf + offset; // GNU extension: void* arithmetic +} diff --git a/clang/test/CodeGen/exprs.c b/clang/test/CodeGen/exprs.c index 5cca972..93015da 100644 --- a/clang/test/CodeGen/exprs.c +++ b/clang/test/CodeGen/exprs.c @@ -196,10 +196,17 @@ void f18(void) { // Ensure the right stmt is returned int f19(void) { - return ({ 3;;4;; }); + return ({ 3;;4; }); } // CHECK-LABEL: define{{.*}} i32 @f19() // CHECK: [[T:%.*]] = alloca i32 // CHECK: store i32 4, ptr [[T]] // CHECK: [[L:%.*]] = load i32, ptr [[T]] // CHECK: ret i32 [[L]] + +// PR166036: The trailing NullStmt should result in a void. +void f20(void) { + return ({ 3;;4;; }); +} +// CHECK-LABEL: define{{.*}} void @f20() +// CHECK: ret void diff --git a/clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c b/clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c index 8d4e0c5..443ccbb 100644 --- a/clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c +++ b/clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify %s +// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -Wpointer-arith -verify %s #define __counted_by(f) __attribute__((counted_by(f))) @@ -29,7 +29,9 @@ struct on_member_pointer_const_incomplete_ty { }; struct on_member_pointer_void_ty { - void* buf __counted_by(count); // expected-error{{'counted_by' cannot be applied to a pointer with pointee of unknown size because 'void' is an incomplete type}} + // expected-warning@+2{{'counted_by' on a pointer to void is a GNU extension, treated as 'sized_by'}} + // expected-note@+1{{use '__sized_by' to suppress this warning}} + void* buf __counted_by(count); int count; }; diff --git a/clang/test/Sema/attr-counted-by-or-null-last-field.c b/clang/test/Sema/attr-counted-by-or-null-last-field.c index 60a1f57..d0c50a7 100644 --- a/clang/test/Sema/attr-counted-by-or-null-last-field.c +++ b/clang/test/Sema/attr-counted-by-or-null-last-field.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -verify=expected,immediate %s -// RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes -verify=expected,late %s +// RUN: %clang_cc1 -fsyntax-only -Wpointer-arith -verify=expected,immediate %s +// RUN: %clang_cc1 -fsyntax-only -Wpointer-arith -fexperimental-late-parse-attributes -verify=expected,late %s #define __counted_by_or_null(f) __attribute__((counted_by_or_null(f))) @@ -128,7 +128,9 @@ struct on_member_ptr_incomplete_const_ty_ty_pos { struct on_member_ptr_void_ty_ty_pos { int count; - void * ptr __counted_by_or_null(count); // expected-error {{'counted_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'void' is an incomplete type}} + // expected-warning@+2{{'counted_by_or_null' on a pointer to void is a GNU extension, treated as 'sized_by_or_null'}} + // expected-note@+1{{use '__sized_by_or_null' to suppress this warning}} + void * ptr __counted_by_or_null(count); }; typedef void(fn_ty)(int); diff --git a/clang/test/Sema/attr-counted-by-or-null-late-parsed-struct-ptrs.c b/clang/test/Sema/attr-counted-by-or-null-late-parsed-struct-ptrs.c index 2150c81..233b729 100644 --- a/clang/test/Sema/attr-counted-by-or-null-late-parsed-struct-ptrs.c +++ b/clang/test/Sema/attr-counted-by-or-null-late-parsed-struct-ptrs.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify %s +// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -Wpointer-arith -verify %s #define __counted_by_or_null(f) __attribute__((counted_by_or_null(f))) #define __counted_by(f) __attribute__((counted_by(f))) @@ -30,7 +30,9 @@ struct on_member_pointer_const_incomplete_ty { }; struct on_member_pointer_void_ty { - void* buf __counted_by_or_null(count); // expected-error{{'counted_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'void' is an incomplete type}} + // expected-warning@+2{{'counted_by_or_null' on a pointer to void is a GNU extension, treated as 'sized_by_or_null'}} + // expected-note@+1{{use '__sized_by_or_null' to suppress this warning}} + void* buf __counted_by_or_null(count); int count; }; diff --git a/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c b/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c index 0bb0905..0fd739c 100644 --- a/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c +++ b/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wpointer-arith -verify %s +// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -Wpointer-arith -verify %s #define __counted_by_or_null(f) __attribute__((counted_by_or_null(f))) #define __counted_by(f) __attribute__((counted_by(f))) @@ -32,7 +32,8 @@ struct on_member_pointer_const_incomplete_ty { struct on_member_pointer_void_ty { int count; - // expected-error@+1{{'counted_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'void' is an incomplete type}} + // expected-warning@+2{{'counted_by_or_null' on a pointer to void is a GNU extension, treated as 'sized_by_or_null'}} + // expected-note@+1{{use '__sized_by_or_null' to suppress this warning}} void* buf __counted_by_or_null(count); }; @@ -124,7 +125,8 @@ struct on_member_pointer_const_incomplete_ty_ty_pos { struct on_member_pointer_void_ty_ty_pos { int count; - // expected-error@+1{{'counted_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'void' is an incomplete type}} + // expected-warning@+2{{'counted_by_or_null' on a pointer to void is a GNU extension, treated as 'sized_by_or_null'}} + // expected-note@+1{{use '__sized_by_or_null' to suppress this warning}} void *__counted_by_or_null(count) buf; }; diff --git a/clang/test/Sema/attr-counted-by-struct-ptrs.c b/clang/test/Sema/attr-counted-by-struct-ptrs.c index c05d182..a42f389 100644 --- a/clang/test/Sema/attr-counted-by-struct-ptrs.c +++ b/clang/test/Sema/attr-counted-by-struct-ptrs.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes %s -verify +// RUN: %clang_cc1 -fsyntax-only -Wpointer-arith -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wpointer-arith -fexperimental-late-parse-attributes %s -verify #define __counted_by(f) __attribute__((counted_by(f))) @@ -31,7 +31,8 @@ struct on_member_pointer_const_incomplete_ty { struct on_member_pointer_void_ty { int count; - // expected-error@+1{{'counted_by' cannot be applied to a pointer with pointee of unknown size because 'void' is an incomplete type}} + // expected-warning@+2{{'counted_by' on a pointer to void is a GNU extension, treated as 'sized_by'}} + // expected-note@+1{{use '__sized_by' to suppress this warning}} void* buf __counted_by(count); }; @@ -123,7 +124,8 @@ struct on_member_pointer_const_incomplete_ty_ty_pos { struct on_member_pointer_void_ty_ty_pos { int count; - // expected-error@+1{{'counted_by' cannot be applied to a pointer with pointee of unknown size because 'void' is an incomplete type}} + // expected-warning@+2{{'counted_by' on a pointer to void is a GNU extension, treated as 'sized_by'}} + // expected-note@+1{{use '__sized_by' to suppress this warning}} void *__counted_by(count) buf; }; diff --git a/clang/test/Sema/attr-counted-by-void-ptr-gnu.c b/clang/test/Sema/attr-counted-by-void-ptr-gnu.c new file mode 100644 index 0000000..c1ed5f8 --- /dev/null +++ b/clang/test/Sema/attr-counted-by-void-ptr-gnu.c @@ -0,0 +1,101 @@ +// RUN: %clang_cc1 -fsyntax-only -verify=expected-nowarn %s +// RUN: %clang_cc1 -Wpointer-arith -fsyntax-only -verify=expected-warn %s +// RUN: %clang_cc1 -fexperimental-bounds-safety -fsyntax-only -verify=expected-bounds %s + +// expected-nowarn-no-diagnostics +// expected-bounds-no-diagnostics + +#define NULL (void*)0 +#define __counted_by(f) __attribute__((counted_by(f))) +#define __counted_by_or_null(f) __attribute__((counted_by_or_null(f))) +#define __sized_by(f) __attribute__((sized_by(f))) + +//============================================================================== +// Test: counted_by on void* is allowed (warns with -Wpointer-arith) +//============================================================================== + +struct test_void_ptr_gnu { + int count; + // expected-warn-warning@+2{{'counted_by' on a pointer to void is a GNU extension, treated as 'sized_by'}} + // expected-warn-note@+1{{use '__sized_by' to suppress this warning}} + void* buf __counted_by(count); +}; + +struct test_const_void_ptr_gnu { + int count; + // expected-warn-warning@+2{{'counted_by' on a pointer to void is a GNU extension, treated as 'sized_by'}} + // expected-warn-note@+1{{use '__sized_by' to suppress this warning}} + const void* buf __counted_by(count); +}; + +struct test_volatile_void_ptr_gnu { + int count; + // expected-warn-warning@+2{{'counted_by' on a pointer to void is a GNU extension, treated as 'sized_by'}} + // expected-warn-note@+1{{use '__sized_by' to suppress this warning}} + volatile void* buf __counted_by(count); +}; + +struct test_const_volatile_void_ptr_gnu { + int count; + // expected-warn-warning@+2{{'counted_by' on a pointer to void is a GNU extension, treated as 'sized_by'}} + // expected-warn-note@+1{{use '__sized_by' to suppress this warning}} + const volatile void* buf __counted_by(count); +}; + +// Verify sized_by still works the same way (always allowed, no warning) +struct test_sized_by_void_ptr { + int size; + void* buf __sized_by(size); // OK in both modes, no warning +}; + +//============================================================================== +// Test: counted_by_or_null on void* behaves the same +//============================================================================== + +struct test_void_ptr_or_null_gnu { + int count; + // expected-warn-warning@+2{{'counted_by_or_null' on a pointer to void is a GNU extension, treated as 'sized_by_or_null'}} + // expected-warn-note@+1{{use '__sized_by_or_null' to suppress this warning}} + void* buf __counted_by_or_null(count); +}; + +struct test_const_void_ptr_or_null_gnu { + int count; + // expected-warn-warning@+2{{'counted_by_or_null' on a pointer to void is a GNU extension, treated as 'sized_by_or_null'}} + // expected-warn-note@+1{{use '__sized_by_or_null' to suppress this warning}} + const void* buf __counted_by_or_null(count); +}; + +//============================================================================== +// Test: Using void* __counted_by(...) pointers (not just declaring them) +//============================================================================== + +// Verify that void* __counted_by pointers can be used as rvalues, assigned to, +// passed to functions, etc. + +void* use_as_rvalue(struct test_void_ptr_gnu* t) { + return t->buf; +} + +void assign_to_pointer(struct test_void_ptr_gnu* t) { + t->buf = NULL; + t->count = 0; +} + +extern void* my_allocator(unsigned long); + +void assign_from_allocator(struct test_void_ptr_gnu* t) { + t->buf = my_allocator(100); + t->count = 100; +} + +void takes_void_ptr(void* p); + +void pass_to_function(struct test_void_ptr_gnu* t) { + takes_void_ptr(t->buf); +} + +void* pointer_arithmetic(struct test_void_ptr_gnu* t) { + // expected-warn-warning@+1{{arithmetic on a pointer to void is a GNU extension}} + return t->buf + 10; +} diff --git a/clang/test/Sema/statements.c b/clang/test/Sema/statements.c index d44ab5a..28740fa2 100644 --- a/clang/test/Sema/statements.c +++ b/clang/test/Sema/statements.c @@ -119,14 +119,15 @@ void test_pr22849(void) { }; } -// GCC ignores empty statements at the end of compound expressions where the -// result type is concerned. +// Empty statements at the end of compound expressions have a result type 'void'. void test13(void) { int a; a = ({ 1; }); - a = ({1;; }); + a = ({ 1; 2; }); // expected-warning {{expression result unused}} + a = ({ 1;; }); // expected-error {{assigning to 'int' from incompatible type 'void'}} + // expected-warning@-1 {{expression result unused}} a = ({int x = 1; (void)x; }); // expected-error {{assigning to 'int' from incompatible type 'void'}} - a = ({int x = 1; (void)x;; }); // expected-error {{assigning to 'int' from incompatible type 'void'}} + a = ({int x = 1;; }); // expected-error {{assigning to 'int' from incompatible type 'void'}} } void test14(void) { return ({}); } diff --git a/clang/test/SemaCUDA/error-includes-mode.cu b/clang/test/SemaCUDA/error-includes-mode.cu index 257fdec..f775e65 100644 --- a/clang/test/SemaCUDA/error-includes-mode.cu +++ b/clang/test/SemaCUDA/error-includes-mode.cu @@ -1,7 +1,16 @@ // RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck --check-prefix HOST %s // RUN: not %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_35 \ // RUN: -fcuda-is-device -fsyntax-only %s 2>&1 | FileCheck --check-prefix SM35 %s +// RUN: not %clang_cc1 -triple spirv64-unknown-unknown \ +// RUN: -fcuda-is-device -fsyntax-only %s 2>&1 | FileCheck --check-prefix SPIRV %s +// RUN: not %clang_cc1 -triple spirv64-amd-amdhsa \ +// RUN: -fcuda-is-device -fsyntax-only %s 2>&1 | FileCheck --check-prefix AMDGCNSPIRV %s +// RUN: not %clang_cc1 -triple spirv64-intel-unknown \ +// RUN: -fcuda-is-device -fsyntax-only %s 2>&1 | FileCheck --check-prefix INTELSPIRV %s // HOST: 1 error generated when compiling for host // SM35: 1 error generated when compiling for sm_35 +// SPIRV: 1 error generated when compiling for spirv64-unknown-unknown +// AMDGCNSPIRV: 1 error generated when compiling for spirv64-amd-amdhsa +// INTELSPIRV: 1 error generated when compiling for spirv64-intel-unknown error; diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp index 331fe83..ff10424 100644 --- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp +++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -std=c++2a -Wno-unused-value %s -verify +// RUN: %clang_cc1 -std=c++2a -Wno-unused-value %s -verify -fexperimental-new-constant-interpreter // RUN: %clang_cc1 -std=c++2b -Wno-unused-value %s -verify +// RUN: %clang_cc1 -std=c++2b -Wno-unused-value %s -verify -fexperimental-new-constant-interpreter consteval int id(int i) { return i; } constexpr char id(char c) { return c; } diff --git a/clang/test/SemaCXX/statements.cpp b/clang/test/SemaCXX/statements.cpp index 48f178d..426e9fa 100644 --- a/clang/test/SemaCXX/statements.cpp +++ b/clang/test/SemaCXX/statements.cpp @@ -43,8 +43,6 @@ T test7(T v) { return ({ // expected-warning{{use of GNU statement expression extension}} T a = v; a; - ; - ; }); } @@ -53,6 +51,21 @@ void test8() { double b = test7(2.0); } +template <typename T> +T test9(T v) { + return ({ // expected-warning {{use of GNU statement expression extension}} + T a = v; + a; // expected-warning {{expression result unused}} + ; + ; + }); +} + +void test10() { + int a = test9(1); // expected-note {{in instantiation of function template specialization 'test9<int>' requested here}} + // expected-error@-10 {{cannot initialize return object of type 'int' with an rvalue of type 'void'}} +} + namespace GH48405 { void foo() { struct S { |
