diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/AST/ByteCode/builtin-object-size.cpp | 3 | ||||
-rw-r--r-- | clang/test/CodeGen/X86/avx512fp16-builtins.c | 4 | ||||
-rw-r--r-- | clang/test/Sema/format-strings-signedness.cpp | 30 | ||||
-rw-r--r-- | clang/test/SemaTemplate/concepts.cpp | 41 |
4 files changed, 76 insertions, 2 deletions
diff --git a/clang/test/AST/ByteCode/builtin-object-size.cpp b/clang/test/AST/ByteCode/builtin-object-size.cpp index 6f4ef54..e4433ea 100644 --- a/clang/test/AST/ByteCode/builtin-object-size.cpp +++ b/clang/test/AST/ByteCode/builtin-object-size.cpp @@ -17,7 +17,8 @@ static_assert(__builtin_object_size(&arrf, 0) == (sizeof(float)*2), ""); static_assert(__builtin_object_size(&arrf[1], 0) == sizeof(float), ""); static_assert(__builtin_object_size(&arrf[2], 0) == 0, ""); - +constexpr struct { int a; int b; } F{}; +static_assert(__builtin_object_size(&F.a, 3) == sizeof(int)); struct S { int a; diff --git a/clang/test/CodeGen/X86/avx512fp16-builtins.c b/clang/test/CodeGen/X86/avx512fp16-builtins.c index dbf89b3..2befff0 100644 --- a/clang/test/CodeGen/X86/avx512fp16-builtins.c +++ b/clang/test/CodeGen/X86/avx512fp16-builtins.c @@ -117,6 +117,7 @@ __m512h test_mm512_set1_pch(_Float16 _Complex h) { // CHECK: bitcast <16 x float>{{.*}} to <32 x half> return _mm512_set1_pch(h); } +TEST_CONSTEXPR(match_m512h(_mm512_set1_pch(1.0), 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0)); __m512h test_mm512_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8, @@ -340,18 +341,21 @@ __m128h test_mm256_castph256_ph128(__m256h __a) { // CHECK: shufflevector <16 x half> %{{.*}}, <16 x half> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> return _mm256_castph256_ph128(__a); } +TEST_CONSTEXPR(match_m128h(_mm256_castph256_ph128((__m256h){-1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0, -13.0, 14.0, -15.0, -16.0}), -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0)); __m128h test_mm512_castph512_ph128(__m512h __a) { // CHECK-LABEL: test_mm512_castph512_ph128 // CHECK: shufflevector <32 x half> %{{.*}}, <32 x half> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> return _mm512_castph512_ph128(__a); } +TEST_CONSTEXPR(match_m128h(_mm512_castph512_ph128((__m512h){0.0, -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0, -13.0, 14.0, -15.0, -16.0, -17.0, 18.0, -19.0, 20.0, -21.0, 22.0, -23.0, 24.0, -25.0, 26.0, -27.0, 28.0, -29.0, 30.0, -31.0}), 0.0, -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0)); __m256h test_mm512_castph512_ph256(__m512h __a) { // CHECK-LABEL: test_mm512_castph512_ph256 // CHECK: shufflevector <32 x half> %{{.*}}, <32 x half> %{{.*}}, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15> return _mm512_castph512_ph256(__a); } +TEST_CONSTEXPR(match_m256h(_mm512_castph512_ph256((__m512h){-1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0, -13.0, 14.0, -15.0, -16.0, -17.0, 18.0, -19.0, 20.0, -21.0, 22.0, -23.0, 24.0, -25.0, 26.0, -27.0, 28.0, -29.0, 30.0, -31.0, 32.0}), -1.0, 2.0, -3.0, 4.0, -5.0, 6.0, -7.0, 8.0, -9.0, 10.0, -11.0, 12.0, -13.0, 14.0, -15.0, -16.0)); __m256h test_mm256_castph128_ph256(__m128h __a) { // CHECK-LABEL: test_mm256_castph128_ph256 diff --git a/clang/test/Sema/format-strings-signedness.cpp b/clang/test/Sema/format-strings-signedness.cpp new file mode 100644 index 0000000..66bf1de --- /dev/null +++ b/clang/test/Sema/format-strings-signedness.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wformat -Wformat-signedness %s +// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -verify -Wformat -Wformat-signedness %s + +// Verify that -Wformat-signedness alone (without -Wformat) trigger the +// warnings. Note in gcc this will not trigger the signedness warnings as +// -Wformat is default off in gcc. +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wformat-signedness %s +// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -verify -Wformat-signedness %s + +// Verify that -Wformat-signedness warnings are not reported with only -Wformat +// (gcc compat). +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -Wformat -verify=okay %s + +// Verify that -Wformat-signedness with -Wno-format are not reported (gcc compat). +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -Wformat-signedness -Wno-format -verify=okay %s +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -Wno-format -Wformat-signedness -verify=okay %s +// okay-no-diagnostics + +// Ignore 'GCC requires a function with the 'format' attribute to be variadic'. +#pragma GCC diagnostic ignored "-Wgcc-compat" +namespace GH161075 { +template <typename... Args> +void format(const char *fmt, Args &&...args) + __attribute__((format(printf, 1, 2))); + +void do_format() { + bool b = false; + format("%hhi %hhu %hi %hu %i %u", b, b, b, b, b, b); // expected-warning {{format specifies type 'unsigned char' but the argument has type 'bool', which differs in signedness}} +} +} // namespace GH161075 diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp index e5e081f..3b7c138 100644 --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -std=c++20 -ferror-limit 0 -verify %s +// RUN: %clang_cc1 -std=c++20 -ferror-limit 0 -verify=expected,cxx20 %s +// RUN: %clang_cc1 -std=c++2c -ferror-limit 0 -verify=expected %s namespace PR47043 { template<typename T> concept True = true; @@ -1405,3 +1406,41 @@ static_assert(!std::is_constructible_v<span<4>, array<int, 3>>); } } + + +namespace GH162125 { +template<typename, int size> +concept true_int = (size, true); + +template<typename, typename... Ts> +concept true_types = true_int<void, sizeof...(Ts)>; + +template<typename, typename... Ts> +concept true_types2 = true_int<void, Ts...[0]{1}>; // cxx20-warning {{pack indexing is a C++2c extension}} + +template<typename... Ts> +struct s { + template<typename T> requires true_types<T, Ts...> && true_types2<T, Ts...> + static void f(T); +}; +void(*test)(int) = &s<bool>::f<int>; +} + +namespace GH162125_reversed { +template<int size, typename> +concept true_int = (size, true); + +template<typename, typename... Ts> +concept true_types = true_int<sizeof...(Ts), void>; + +template<typename, typename... Ts> +concept true_types2 = true_int<Ts...[0]{1}, void>; // cxx20-warning {{pack indexing is a C++2c extension}} + +template<typename... Ts> +struct s { + template<typename T> requires true_types<T, Ts...> && true_types2<T, Ts...> + static void f(T); +}; + +void(*test)(int) = &s<bool>::f<int>; +} |