diff options
author | Douglas Gregor <dgregor@apple.com> | 2017-09-14 23:38:42 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2017-09-14 23:38:42 +0000 |
commit | 672281a5116d255e8f18254301d907022f13e4df (patch) | |
tree | b6808068bd59995d4ba37af3485ce5aef3616a31 /clang/test/SemaCXX/static-assert.cpp | |
parent | bb26f86e6fad024df1a0328a3b09813ed4ccb858 (diff) | |
download | bcm5719-llvm-672281a5116d255e8f18254301d907022f13e4df.tar.gz bcm5719-llvm-672281a5116d255e8f18254301d907022f13e4df.zip |
Diagnostic specific failed condition in a static_assert.
When a static_assert fails, dig out a specific condition to diagnose,
using the same logic that we use to find the enable_if condition to
diagnose.
llvm-svn: 313315
Diffstat (limited to 'clang/test/SemaCXX/static-assert.cpp')
-rw-r--r-- | clang/test/SemaCXX/static-assert.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/static-assert.cpp b/clang/test/SemaCXX/static-assert.cpp index 196375c3d68..846303807a0 100644 --- a/clang/test/SemaCXX/static-assert.cpp +++ b/clang/test/SemaCXX/static-assert.cpp @@ -51,3 +51,20 @@ StaticAssertProtected<X> sap2; // expected-note {{instantiation}} static_assert(true); // expected-warning {{C++17 extension}} static_assert(false); // expected-error-re {{failed{{$}}}} expected-warning {{extension}} + + +// Diagnostics for static_assert with multiple conditions +template<typename T> struct first_trait { + static const bool value = false; +}; + +template<> +struct first_trait<X> { + static const bool value = true; +}; + +template<typename T> struct second_trait { + static const bool value = false; +}; + +static_assert(first_trait<X>::value && second_trait<X>::value, "message"); // expected-error{{static_assert failed due to requirement 'second_trait<X>::value' "message"}} |