summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/conversion-function.cpp
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2009-10-14 18:03:49 +0000
committerrdivacky <rdivacky@FreeBSD.org>2009-10-14 18:03:49 +0000
commit9092c3e0fa01f3139b016d05d267a89e3b07747a (patch)
tree137ebebcae16fb0ce7ab4af456992bbd8d22fced /test/SemaCXX/conversion-function.cpp
parent4981926bf654fe5a2c3893f24ca44106b217e71e (diff)
downloadFreeBSD-src-9092c3e0fa01f3139b016d05d267a89e3b07747a.zip
FreeBSD-src-9092c3e0fa01f3139b016d05d267a89e3b07747a.tar.gz
Update clang to r84119.
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