summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/conversion-function.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/conversion-function.cpp')
-rw-r--r--test/SemaCXX/conversion-function.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp
index 1ca1e68..6182678 100644
--- a/test/SemaCXX/conversion-function.cpp
+++ b/test/SemaCXX/conversion-function.cpp
@@ -64,3 +64,32 @@ struct Flip {
operator Flop() const;
};
Flop flop = Flip(); // expected-error {{cannot initialize 'flop' with an rvalue of type 'struct Flip'}}
+
+// This tests that we don't add the second conversion declaration to the list of user conversions
+struct C {
+ operator const char *() const;
+};
+
+C::operator const char*() const { return 0; }
+
+void f(const C& c) {
+ const char* v = c;
+}
+
+// Test. Conversion in base class is visible in derived class.
+class XB {
+public:
+ operator int(); // expected-note {{candidate function}}
+};
+
+class Yb : public XB {
+public:
+ operator char(); // expected-note {{candidate function}}
+};
+
+void f(Yb& a) {
+ if (a) { } // expected-error {{conversion from 'class Yb' to 'bool' is ambiguous}}
+ int i = a; // OK. calls XB::operator int();
+ char ch = a; // OK. calls Yb::operator char();
+}
+
OpenPOWER on IntegriCloud