diff options
author | Clement Courbet <courbet@google.com> | 2018-12-10 08:19:38 +0000 |
---|---|---|
committer | Clement Courbet <courbet@google.com> | 2018-12-10 08:19:38 +0000 |
commit | 057f7695de385511c042e14542e0d3414109b267 (patch) | |
tree | aca6eeae6c77f70c4c0de2d64156eb95fd2746eb /clang/test/SemaCXX/static-assert.cpp | |
parent | 7b475f3b412506b6fe7b65b389c91ac285dd090d (diff) | |
download | bcm5719-llvm-057f7695de385511c042e14542e0d3414109b267.tar.gz bcm5719-llvm-057f7695de385511c042e14542e0d3414109b267.zip |
[Sema] Further improvements to to static_assert diagnostics.
Summary:
We're now handling cases like `static_assert(!expr)` and
static_assert(!(expr))`.
Reviewers: aaron.ballman, Quuxplusone
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D55270
llvm-svn: 348741
Diffstat (limited to 'clang/test/SemaCXX/static-assert.cpp')
-rw-r--r-- | clang/test/SemaCXX/static-assert.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/test/SemaCXX/static-assert.cpp b/clang/test/SemaCXX/static-assert.cpp index 38f82091ae7..b43d56a922c 100644 --- a/clang/test/SemaCXX/static-assert.cpp +++ b/clang/test/SemaCXX/static-assert.cpp @@ -15,14 +15,14 @@ class C { }; template<int N> struct T { - static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed "N is not 2!"}} + static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed due to requirement '1 == 2' "N is not 2!"}} }; T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}} T<2> t2; template<typename T> struct S { - static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static_assert failed "Type not big enough!"}} + static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static_assert failed due to requirement 'sizeof(char) > sizeof(char)' "Type not big enough!"}} }; S<char> s1; // expected-note {{in instantiation of template class 'S<char>' requested here}} @@ -111,6 +111,14 @@ static_assert(std::is_same<ExampleTypes::T, ExampleTypes::U>::value, "message"); // expected-error@-1{{static_assert failed due to requirement 'std::is_same<int, float>::value' "message"}} static_assert(std::is_const<ExampleTypes::T>::value, "message"); // expected-error@-1{{static_assert failed due to requirement 'std::is_const<int>::value' "message"}} +static_assert(!std::is_const<const ExampleTypes::T>::value, "message"); +// expected-error@-1{{static_assert failed due to requirement '!std::is_const<const int>::value' "message"}} +static_assert(!(std::is_const<const ExampleTypes::T>::value), "message"); +// expected-error@-1{{static_assert failed due to requirement '!(std::is_const<const int>::value)' "message"}} +static_assert(std::is_const<const ExampleTypes::T>::value == false, "message"); +// expected-error@-1{{static_assert failed due to requirement 'std::is_const<const int>::value == false' "message"}} +static_assert(!(std::is_const<const ExampleTypes::T>::value == true), "message"); +// expected-error@-1{{static_assert failed due to requirement '!(std::is_const<const int>::value == true)' "message"}} struct BI_tag {}; struct RAI_tag : BI_tag {}; |