diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-19 22:01:37 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-19 22:01:37 +0000 |
| commit | d0b111c3ddfd53869e00f92e782a9373a176cf0e (patch) | |
| tree | 2266e06eea4dcd2850d6587882e4404c075fbcba /clang/test/SemaCXX/constant-expression-cxx11.cpp | |
| parent | 4266a7935191d8111e6bfa0de2ce0eec98678201 (diff) | |
| download | bcm5719-llvm-d0b111c3ddfd53869e00f92e782a9373a176cf0e.tar.gz bcm5719-llvm-d0b111c3ddfd53869e00f92e782a9373a176cf0e.zip | |
Improve r146813 (for PR11595) to give an appropriate diagnostic.
llvm-svn: 146915
Diffstat (limited to 'clang/test/SemaCXX/constant-expression-cxx11.cpp')
| -rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx11.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp index 94da73fcf6a..e4ada1ed832 100644 --- a/clang/test/SemaCXX/constant-expression-cxx11.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp @@ -915,6 +915,11 @@ static_assert(makeComplexWrap(1,0) != complex(0, 1), ""); namespace PR11595 { struct A { constexpr bool operator==(int x) { return true; } }; - struct B { B(); ~B(); A& x; }; - static_assert(B().x == 3, ""); // expected-error {{constant expression}} + struct B { B(); A& x; }; + static_assert(B().x == 3, ""); // expected-error {{constant expression}} expected-note {{non-literal type 'PR11595::B' cannot be used in a constant expression}} + + constexpr bool f(int k) { + return B().x == k; // expected-note {{non-literal type 'PR11595::B' cannot be used in a constant expression}} + } + constexpr int n = f(1); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'f(1)'}} } |

