diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-11 22:37:56 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-11 22:37:56 +0000 |
| commit | e3f470a718ec00eb8b546e405fa59bc2df2d7c46 (patch) | |
| tree | da7223195380885f10c3fb658c4320a8667787e3 /test/SemaCXX/static-assert.cpp | |
| parent | 18b7f95bdbfbd90c1f8e027225fb2cb8fca7134a (diff) | |
| download | clang-e3f470a718ec00eb8b546e405fa59bc2df2d7c46.tar.gz clang-e3f470a718ec00eb8b546e405fa59bc2df2d7c46.tar.bz2 clang-e3f470a718ec00eb8b546e405fa59bc2df2d7c46.tar.xz | |
Stop instantiating a class if we hit a static_assert failure. Also, if the
static_assert fails when parsing the template, don't diagnose it again on every
instantiation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160088 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/static-assert.cpp')
| -rw-r--r-- | test/SemaCXX/static-assert.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/SemaCXX/static-assert.cpp b/test/SemaCXX/static-assert.cpp index 364e4e4bef..4a7560ba5b 100644 --- a/test/SemaCXX/static-assert.cpp +++ b/test/SemaCXX/static-assert.cpp @@ -34,3 +34,17 @@ static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u" static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}} static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}} static_assert(false, L"\x1ff" "0\x123" "fx\xfffff" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFFFFFgoop"}} + +template<typename T> struct AlwaysFails { + // Only give one error here. + static_assert(false, ""); // expected-error {{static_assert failed}} +}; +AlwaysFails<int> alwaysFails; + +template<typename T> struct StaticAssertProtected { + static_assert(__is_literal(T), ""); // expected-error {{static_assert failed}} + static constexpr T t = {}; // no error here +}; +struct X { ~X(); }; +StaticAssertProtected<int> sap1; +StaticAssertProtected<X> sap2; // expected-note {{instantiation}} |
