diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-08 06:13:49 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-08 06:13:49 +0000 |
commit | 50d61c8ccfc633b13cdf594ea3cd3a217076debe (patch) | |
tree | f63370170c819067707d15dba92ee4c14362c712 /test/SemaCXX/conditional-expr.cpp | |
parent | 9a58584bb13d725ecb1ac70ce91c6ac52daa9484 (diff) |
Implement final piece of DR963 and also DR587:
A conditional operator between glvalues of types cv1 T and cv2 T produces a
glvalue if the expressions are of the same value kind and one of cv1 and cv2
is a subset of the other.
A conditional operator between two null pointer constants is permitted if one
of them is of type std::nullptr_t.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161476 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/conditional-expr.cpp')
-rw-r--r-- | test/SemaCXX/conditional-expr.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp index 4aee913277..a80eda416f 100644 --- a/test/SemaCXX/conditional-expr.cpp +++ b/test/SemaCXX/conditional-expr.cpp @@ -2,7 +2,7 @@ // C++ rules for ?: are a lot stricter than C rules, and have to take into // account more conversion options. -// This test runs in C++0x mode for the contextual conversion of the condition. +// This test runs in C++11 mode for the contextual conversion of the condition. struct ToBool { explicit operator bool(); }; @@ -328,3 +328,27 @@ namespace PR9236 { (void)(true ? (void*)0 : A()); // expected-error{{incompatible operand types}} } } + +namespace DR587 { + template<typename T> + const T *f(bool b) { + static T t1 = T(); + static const T t2 = T(); + return &(b ? t1 : t2); + } + struct S {}; + template const int *f(bool); + template const S *f(bool); + + extern bool b; + int i = 0; + const int ci = 0; + volatile int vi = 0; + const volatile int cvi = 0; + + const int &cir = b ? i : ci; + volatile int &vir = b ? vi : i; + const volatile int &cvir1 = b ? ci : cvi; + const volatile int &cvir2 = b ? cvi : vi; + const volatile int &cvir3 = b ? ci : vi; // expected-error{{volatile lvalue reference to type 'const volatile int' cannot bind to a temporary of type 'int'}} +} |