diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-14 18:03:49 +0000 |
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-14 18:03:49 +0000 |
| commit | 4c8b24812ddcd1dedaca343a6d4e76f91f398981 (patch) | |
| tree | 137ebebcae16fb0ce7ab4af456992bbd8d22fced /test/SemaCXX/conversion-function.cpp | |
| parent | 5362a71c02e7d448a8ce98cf00c47e353fba5d04 (diff) | |
Notes
Diffstat (limited to 'test/SemaCXX/conversion-function.cpp')
| -rw-r--r-- | test/SemaCXX/conversion-function.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp index 1ca1e689eab0..6182678e3113 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(); +} + |
