[PATCH] D75571: [Sema][SVE] Add tests for valid and invalid type usage
This revision was automatically updated to reflect the committed changes. rsandifo-arm marked an inline comment as done. Closed by commit rGf09c7d642afa: [Sema][SVE] Add tests for valid and invalid type usage (authored by rsandifo-arm). Changed prior to commit: https://reviews.llvm.org/D75571?vs=248601&id=249971#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75571/new/ https://reviews.llvm.org/D75571 Files: clang/test/Sema/sizeless-1.c clang/test/SemaCXX/sizeless-1.cpp Index: clang/test/SemaCXX/sizeless-1.cpp === --- /dev/null +++ clang/test/SemaCXX/sizeless-1.cpp @@ -0,0 +1,469 @@ +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++11 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s + +namespace std { +struct type_info; +} + +typedef __SVInt8_t svint8_t; +typedef __SVInt16_t svint16_t; + +svint8_t *global_int8_ptr; +extern svint8_t *extern_int8_ptr; +static svint8_t *static_int8_ptr; + +typedef svint8_t int8_typedef; +typedef svint8_t *int8_ptr_typedef; + +void pass_int8(svint8_t); // expected-note {{no known conversion}} + +svint8_t return_int8(); + +typedef svint8_t vec_int8_a __attribute__((vector_size(64)));// expected-error {{invalid vector element type}} +typedef svint8_t vec_int8_b __attribute__((ext_vector_type(4))); // expected-error {{invalid vector element type}} + +void dump(const volatile void *); + +void overf(svint8_t); +void overf(svint16_t); + +void overf8(svint8_t); // expected-note + {{not viable}} +void overf8(int); // expected-note + {{not viable}} + +void overf16(svint16_t); // expected-note + {{not viable}} +void overf16(int); // expected-note + {{not viable}} + +void varargs(int, ...); + +void unused() { + svint8_t unused_int8; // expected-warning {{unused}} +} + +struct incomplete_struct *incomplete_ptr; + +void func(int sel) { + svint8_t local_int8; + svint16_t local_int16; + + // Using pointers to sizeless data isn't wrong here, but because the + // type is incomplete, it doesn't provide any alignment guarantees. + _Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), ""); + _Static_assert(__atomic_is_lock_free(2, &local_int8) == __atomic_is_lock_free(2, incomplete_ptr), ""); // expected-error {{static_assert expression is not an integral constant expression}} + _Static_assert(__atomic_always_lock_free(1, &local_int8) == __atomic_always_lock_free(1, incomplete_ptr), ""); + + local_int8; // expected-warning {{expression result unused}} + + (void)local_int8; + + local_int8, 0; // expected-warning + {{expression result unused}} + + 0, local_int8; // expected-warning + {{expression result unused}} + + svint8_t init_int8 = local_int8; + svint8_t bad_init_int8 = for; // expected-error {{expected expression}} + +#if __cplusplus >= 201103L + int empty_brace_init_int = {}; +#else + int empty_brace_init_int = {}; // expected-error {{scalar initializer cannot be empty}} +#endif + + const svint8_t const_int8 = local_int8; // expected-note {{declared const here}} + const svint8_t uninit_const_int8; // expected-error {{default initialization of an object of const type 'const svint8_t'}} + + volatile svint8_t volatile_int8; + + const volatile svint8_t const_volatile_int8 = local_int8; // expected-note {{declared const here}} + const volatile svint8_t uninit_const_volatile_int8; // expected-error {{default initialization of an object of const type 'const volatile svint8_t'}} + + __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or reference}} + + bool test_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'bool' with an lvalue of type 'svint8_t'}} + + int int_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'svint8_t'}} + + init_int8 = local_int8; + init_int8 = local_int16; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'svint16_t'}} + init_int8 = sel; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'int'}} + + sel = local_int8; // expected-error {{assigning to 'int' from incompatible type 'svint8_t'}} + + local_int8 = (svint8_t)local_int8; + local_int8 = (const svint8_t)local_int8; + local_int8 = (svint8_t)local_int16; // expected-error {{C-style cast from 'svint16_t' (aka '__SVInt16_t') to 'svint8_t
[PATCH] D75571: [Sema][SVE] Add tests for valid and invalid type usage
efriedma accepted this revision. efriedma added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75571/new/ https://reviews.llvm.org/D75571 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D75571: [Sema][SVE] Add tests for valid and invalid type usage
rsandifo-arm marked 2 inline comments as done. rsandifo-arm added inline comments. Comment at: clang/test/SemaCXX/sizeless-1.cpp:8 +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s + efriedma wrote: > This is a lot of RUN lines (both here and in the other file). Are you really > getting any significant benefit from them? Yeah, I probably went a bit overboard there. The idea originally was to make sure that sizeless types worked with every standard, but of course that list is going to get out of date fast. (E.g. it predated C++20.) I've now restricted it to: * the earliest standard * standards that are tested explicitly in preprocessor conditions * one gnu standard per test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75571/new/ https://reviews.llvm.org/D75571 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D75571: [Sema][SVE] Add tests for valid and invalid type usage
rsandifo-arm updated this revision to Diff 248601. rsandifo-arm added a comment. Changes in v3: - Prune the number of RUN: lines. - Minor tweaks to the tests themselves. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75571/new/ https://reviews.llvm.org/D75571 Files: clang/test/Sema/sizeless-1.c clang/test/SemaCXX/sizeless-1.cpp Index: clang/test/SemaCXX/sizeless-1.cpp === --- /dev/null +++ clang/test/SemaCXX/sizeless-1.cpp @@ -0,0 +1,469 @@ +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++11 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s + +namespace std { +struct type_info; +} + +typedef __SVInt8_t svint8_t; +typedef __SVInt16_t svint16_t; + +svint8_t *global_int8_ptr; +extern svint8_t *extern_int8_ptr; +static svint8_t *static_int8_ptr; + +typedef svint8_t int8_typedef; +typedef svint8_t *int8_ptr_typedef; + +void pass_int8(svint8_t); // expected-note {{no known conversion}} + +svint8_t return_int8(); + +typedef svint8_t vec_int8_a __attribute__((vector_size(64)));// expected-error {{invalid vector element type}} +typedef svint8_t vec_int8_b __attribute__((ext_vector_type(4))); // expected-error {{invalid vector element type}} + +void dump(const volatile void *); + +void overf(svint8_t); +void overf(svint16_t); + +void overf8(svint8_t); // expected-note + {{not viable}} +void overf8(int); // expected-note + {{not viable}} + +void overf16(svint16_t); // expected-note + {{not viable}} +void overf16(int); // expected-note + {{not viable}} + +void varargs(int, ...); + +void unused() { + svint8_t unused_int8; // expected-warning {{unused}} +} + +struct incomplete_struct *incomplete_ptr; + +void func(int sel) { + svint8_t local_int8; + svint16_t local_int16; + + // Using pointers to sizeless data isn't wrong here, but because the + // type is incomplete, it doesn't provide any alignment guarantees. + _Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), ""); + _Static_assert(__atomic_is_lock_free(2, &local_int8) == __atomic_is_lock_free(2, incomplete_ptr), ""); // expected-error {{static_assert expression is not an integral constant expression}} + _Static_assert(__atomic_always_lock_free(1, &local_int8) == __atomic_always_lock_free(1, incomplete_ptr), ""); + + local_int8; // expected-warning {{expression result unused}} + + (void)local_int8; + + local_int8, 0; // expected-warning + {{expression result unused}} + + 0, local_int8; // expected-warning + {{expression result unused}} + + svint8_t init_int8 = local_int8; + svint8_t bad_init_int8 = for; // expected-error {{expected expression}} + +#if __cplusplus >= 201103L + int empty_brace_init_int = {}; +#else + int empty_brace_init_int = {}; // expected-error {{scalar initializer cannot be empty}} +#endif + + const svint8_t const_int8 = local_int8; // expected-note {{declared const here}} + const svint8_t uninit_const_int8; // expected-error {{default initialization of an object of const type 'const svint8_t'}} + + volatile svint8_t volatile_int8; + + const volatile svint8_t const_volatile_int8 = local_int8; // expected-note {{declared const here}} + const volatile svint8_t uninit_const_volatile_int8; // expected-error {{default initialization of an object of const type 'const volatile svint8_t'}} + + __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or reference}} + + bool test_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'bool' with an lvalue of type 'svint8_t'}} + + int int_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'svint8_t'}} + + init_int8 = local_int8; + init_int8 = local_int16; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'svint16_t'}} + init_int8 = sel; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'int'}} + + sel = local_int8; // expected-error {{assigning to 'int' from incompatible type 'svint8_t'}} + + local_int8 = (svint8_t)local_int8; + local_int8 = (const svint8_t)local_int8; + local_int8 = (svint8_t)local_int16; // expected-error {{C-style cast from 'svint16_t' (aka '__SVInt16_t') to 'svint8_t' (aka '__SVInt8_t') is not allowed}} + local_int8 = (svint8_t)0; // expected-error {{C-style cast from 'int' to 'svint8_t' (aka '__SVInt
[PATCH] D75571: [Sema][SVE] Add tests for valid and invalid type usage
efriedma added inline comments. Comment at: clang/test/SemaCXX/sizeless-1.cpp:8 +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s + This is a lot of RUN lines (both here and in the other file). Are you really getting any significant benefit from them? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75571/new/ https://reviews.llvm.org/D75571 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D75571: [Sema][SVE] Add tests for valid and invalid type usage
rsandifo-arm updated this revision to Diff 248135. rsandifo-arm added a comment. Changes in v2: - Reformat the tests using git-clang-format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75571/new/ https://reviews.llvm.org/D75571 Files: clang/test/Sema/sizeless-1.c clang/test/SemaCXX/sizeless-1.cpp Index: clang/test/SemaCXX/sizeless-1.cpp === --- /dev/null +++ clang/test/SemaCXX/sizeless-1.cpp @@ -0,0 +1,464 @@ +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++98 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++11 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++11 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++14 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++14 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s + +namespace std { +struct type_info; +} + +typedef __SVInt8_t svint8_t; +typedef __SVInt16_t svint16_t; + +svint8_t *global_int8_ptr; +extern svint8_t *extern_int8_ptr; +static svint8_t *static_int8_ptr; + +typedef svint8_t int8_typedef; +typedef svint8_t *int8_ptr_typedef; + +void pass_int8(svint8_t); // expected-note {{no known conversion}} + +svint8_t return_int8(); + +typedef svint8_t vec_int8_a __attribute__((vector_size(64)));// expected-error {{invalid vector element type}} +typedef svint8_t vec_int8_b __attribute__((ext_vector_type(4))); // expected-error {{invalid vector element type}} + +void dump(const volatile void *); + +void overf(svint8_t); +void overf(svint16_t); + +void overf8(svint8_t); // expected-note + {{not viable}} +void overf8(int); // expected-note + {{not viable}} + +void overf16(svint16_t); // expected-note + {{not viable}} +void overf16(int); // expected-note + {{not viable}} + +void varargs(int, ...); + +void unused() { + svint8_t unused_int8; // expected-warning {{unused}} +} + +struct incomplete_struct *incomplete_ptr; + +void func(int sel) { + svint8_t local_int8; + svint16_t local_int16; + + // Using pointers to sizeless data isn't wrong here, but because the + // type is incomplete, it doesn't provide any alignment guarantees. + _Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), ""); + _Static_assert(__atomic_is_lock_free(2, &local_int8) == __atomic_is_lock_free(2, incomplete_ptr), ""); // expected-error {{static_assert expression is not an integral constant expression}} + _Static_assert(__atomic_always_lock_free(1, &local_int8) == __atomic_always_lock_free(1, incomplete_ptr), ""); + + local_int8; // expected-warning {{expression result unused}} + + (void)local_int8; + + local_int8, 0; // expected-warning + {{expression result unused}} + + 0, local_int8; // expected-warning + {{expression result unused}} + + svint8_t init_int8 = local_int8; + svint8_t bad_init_int8 = for; // expected-error {{expected expression}} + +#if __cplusplus >= 201103L + int empty_brace_init_int = {}; +#else + int empty_brace_init_int = {}; // expected-error {{scalar initializer cannot be empty}} +#endif + + const svint8_t const_int8 = local_int8; // expected-note {{declared const here}} + const svint8_t uninit_const_int8; // expected-error {{default initialization of an object of const type 'const svint8_t'}} + + volatile svint8_t volatile_int8; + + const volatile svint8_t const_volatile_int8 = local_int8; // expected-note {{declared const here}} + const volatile svint8_t uninit_const_volatile_int8; // expected-error {{default initialization of an object of const type 'const volatile svint8_t'}} + + __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or reference}} + + bool test_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'bool' with an lvalue of type 'svint8_t'}} + + int int_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'svint8_t'}} + + init_int8 = local_int8; + init_int8 = local_int16; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'svint16_t'}} +
[PATCH] D75571: [Sema][SVE] Add tests for valid and invalid type usage
rsandifo-arm created this revision. rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall. Herald added subscribers: cfe-commits, psnobl, jfb, rkruppe, tschuett. Herald added a reviewer: rengolin. Herald added a project: clang. rsandifo-arm added a child revision: D75572: [Sema][SVE] Reject sizeof and alignof for sizeless types. This patch adds C and C++ tests for various uses of SVE types. The tests cover valid uses that are already (correctly) accepted and invalid uses that are already (correctly) rejected. Later patches will expand the tests as they fix other cases.[*] Some of the tests for invalid uses aren't obviously related to scalable vectors. Part of the reason for having them is to make sure that the quality of the error message doesn't regress once/if the types are treated as incomplete types. [X] These later patches all fix invalid uses that are being incorrectly accepted. I don't know of any cases in which valid uses are being incorrectly rejected. In other words, this series is all about diagnosing invalid code rather than enabling something new. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D75571 Files: clang/test/Sema/sizeless-1.c clang/test/SemaCXX/sizeless-1.cpp Index: clang/test/SemaCXX/sizeless-1.cpp === --- /dev/null +++ clang/test/SemaCXX/sizeless-1.cpp @@ -0,0 +1,447 @@ +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++98 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++11 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++11 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++14 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++14 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s +// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s + +namespace std { struct type_info; } + +typedef __SVInt8_t svint8_t; +typedef __SVInt16_t svint16_t; + +svint8_t *global_int8_ptr; +extern svint8_t *extern_int8_ptr; +static svint8_t *static_int8_ptr; + +typedef svint8_t int8_typedef; +typedef svint8_t *int8_ptr_typedef; + +void pass_int8(svint8_t); // expected-note {{no known conversion}} + +svint8_t return_int8(); + +typedef svint8_t vec_int8_a __attribute__((vector_size(64))); // expected-error {{invalid vector element type}} +typedef svint8_t vec_int8_b __attribute__((ext_vector_type(4))); // expected-error {{invalid vector element type}} + +void dump(const volatile void *); + +void overf(svint8_t); +void overf(svint16_t); + +void overf8(svint8_t); // expected-note + {{not viable}} +void overf8(int); // expected-note + {{not viable}} + +void overf16(svint16_t); // expected-note + {{not viable}} +void overf16(int); // expected-note + {{not viable}} + +void varargs(int, ...); + +void unused() { + svint8_t unused_int8; // expected-warning {{unused}} +} + +struct incomplete_struct *incomplete_ptr; + +void func(int sel) { + svint8_t local_int8; + svint16_t local_int16; + + // Using pointers to sizeless data isn't wrong here, but because the + // type is incomplete, it doesn't provide any alignment guarantees. + _Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), ""); + _Static_assert(__atomic_is_lock_free(2, &local_int8) == __atomic_is_lock_free(2, incomplete_ptr), ""); // expected-error {{static_assert expression is not an integral constant expression}} + _Static_assert(__atomic_always_lock_free(1, &local_int8) == __atomic_always_lock_free(1, incomplete_ptr), ""); + + local_int8; // expected-warning {{expression result unused}} + + (void)local_int8; + + local_int8, 0; // expected-warning + {{expression result unused}} + + 0, local_int8; // expected-warning + {{expression result unused}} + + svint8_t init_int8 = local_int8; + svint8_t bad_init_int8 = for; // expected-error {{expected expression}} + +#if __cplusplus >= 201103L + int empty_brace_init_int = {}; +#else + int empty_brace_init_int = {}; // expected-error {{scalar initializer cannot be empty}} +#endif + + const svint8_t const_int8 = local_int8; // expected-note {{declared const here}} + const svint8_t uninit_const_int8; // expected-error {{default initial