summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorJan Korous <jkorous@apple.com>2018-04-11 13:36:29 +0000
committerJan Korous <jkorous@apple.com>2018-04-11 13:36:29 +0000
commitd74ebe22db891a964d77082e42ad18f28d93610a (patch)
treeac88de91261c28a02343da134a56fe976d638570 /clang/test
parenta70512a9587c40e66035c53c170e8d44c8d2e911 (diff)
downloadbcm5719-llvm-d74ebe22db891a964d77082e42ad18f28d93610a.tar.gz
bcm5719-llvm-d74ebe22db891a964d77082e42ad18f28d93610a.zip
[Sema] Fix built-in decrement operator overload resolution
C++ [over.built] p4: "For every pair (T, VQ), where T is an arithmetic type other than bool, and VQ is either volatile or empty, there exist candidate operator functions of the form VQ T& operator--(VQ T&); T operator--(VQ T&, int); " The bool type is in position LastPromotedIntegralType in BuiltinOperatorOverloadBuilder::getArithmeticType::ArithmeticTypes, but addPlusPlusMinusMinusArithmeticOverloads() was expecting it at position 0. Differential Revision: https://reviews.llvm.org/D44988 rdar://problem/34255516 llvm-svn: 329804
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/overloaded-builtin-operators.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/clang/test/SemaCXX/overloaded-builtin-operators.cpp b/clang/test/SemaCXX/overloaded-builtin-operators.cpp
index 7a99a898e20..4fa376aed03 100644
--- a/clang/test/SemaCXX/overloaded-builtin-operators.cpp
+++ b/clang/test/SemaCXX/overloaded-builtin-operators.cpp
@@ -62,6 +62,10 @@ void f(Short s, Long l, Enum1 e1, Enum2 e2, Xpmf pmf) {
// FIXME: should pass (void)static_cast<no&>(islong(e1 % e2));
}
+struct BoolRef {
+ operator bool&();
+};
+
struct ShortRef { // expected-note{{candidate function (the implicit copy assignment operator) not viable}}
#if __cplusplus >= 201103L // C++11 or later
// expected-note@-2 {{candidate function (the implicit move assignment operator) not viable}}
@@ -73,6 +77,10 @@ struct LongRef {
operator volatile long&();
};
+struct FloatRef {
+ operator float&();
+};
+
struct XpmfRef { // expected-note{{candidate function (the implicit copy assignment operator) not viable}}
#if __cplusplus >= 201103L // C++11 or later
// expected-note@-2 {{candidate function (the implicit move assignment operator) not viable}}
@@ -84,13 +92,19 @@ struct E2Ref {
operator E2&();
};
-void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) {
+void g(BoolRef br, ShortRef sr, LongRef lr, FloatRef fr, E2Ref e2_ref, XpmfRef pmf_ref) {
// C++ [over.built]p3
short s1 = sr++;
- // C++ [over.built]p3
+ // C++ [over.built]p4
long l1 = lr--;
+ // C++ [over.built]p4
+ float f1 = fr--;
+
+ // C++ [over.built]p4
+ bool b2 = br--; // expected-error{{cannot decrement value of type 'BoolRef'}}
+
// C++ [over.built]p18
short& sr1 = (sr *= lr);
volatile long& lr1 = (lr *= sr);
OpenPOWER on IntegriCloud