diff options
Diffstat (limited to 'clang/test/SemaCXX')
-rw-r--r-- | clang/test/SemaCXX/conversion-function.cpp | 10 | ||||
-rw-r--r-- | clang/test/SemaCXX/cxx1y-deduced-return-type.cpp | 13 |
2 files changed, 17 insertions, 6 deletions
diff --git a/clang/test/SemaCXX/conversion-function.cpp b/clang/test/SemaCXX/conversion-function.cpp index ede23a2767e..077e4d9f3cc 100644 --- a/clang/test/SemaCXX/conversion-function.cpp +++ b/clang/test/SemaCXX/conversion-function.cpp @@ -172,12 +172,10 @@ namespace source_locations { namespace crazy_declarators { struct A { - (&operator bool())(); // expected-error {{must use a typedef to declare a conversion to 'bool (&)()'}} - - // FIXME: This diagnostic is misleading (the correct spelling - // would be 'operator int*'), but it's a corner case of a - // rarely-used syntax extension. - *operator int(); // expected-error {{must use a typedef to declare a conversion to 'int *'}} + (&operator bool())(); // expected-error {{use a typedef to declare a conversion to 'bool (&)()'}} + *operator int(); // expected-error {{put the complete type after 'operator'}} + // No suggestion of using a typedef here; that's not possible. + template<typename T> (&operator T())(); // expected-error-re {{cannot specify any part of a return type in the declaration of a conversion function{{$}}}} }; } diff --git a/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp b/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp index 60864165954..50e0cf79c57 100644 --- a/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp +++ b/clang/test/SemaCXX/cxx1y-deduced-return-type.cpp @@ -483,3 +483,16 @@ namespace OverloadedOperators { int g = a - a; } } + +namespace TrailingReturnTypeForConversionOperator { + struct X { + operator auto() -> int { return 0; } // expected-error {{cannot specify any part of a return type in the declaration of a conversion function; put the complete type after 'operator'}} + } x; + int k = x.operator auto(); + + struct Y { + operator auto() -> int & { // expected-error {{cannot specify}} + return 0; // expected-error {{cannot bind to}} + } + }; +}; |