diff options
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.robertl/eb22.C')
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.robertl/eb22.C | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb22.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb22.C new file mode 100644 index 000000000..a78ea4108 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb22.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// Ambiguous conversion, three candidates: +// builtin == (int, int), and the two user-defined operators +// Each one requires a user-defined ICS where another uses builtin conversions, +// so none is the best viable function. + +class MyInt +{ +public: + MyInt(int = 0) {} + operator int() const {return 2;} +}; + +bool operator==(const MyInt& a, const int& b) // { dg-message "operator==" } candidate +{ + return (int)a == b; +} + +bool operator==(const MyInt& a, const MyInt& b) // { dg-message "operator==" } candidate +{ + return (int)a == (int)b; +} + +bool f() +{ + return 3 == MyInt(); // { dg-error "ambiguous" "err" } + // { dg-message "operator==" "match candidate text" { target *-*-* } 26 } + // { dg-message "candidates" "note" { target *-*-* } 26 } +} |