diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CXX/drs/dr3xx.cpp | 2 | ||||
-rw-r--r-- | clang/test/FixIt/fixit.cpp | 6 | ||||
-rw-r--r-- | clang/test/SemaCXX/conversion-function.cpp | 10 | ||||
-rw-r--r-- | clang/test/SemaCXX/cxx1y-deduced-return-type.cpp | 13 |
4 files changed, 24 insertions, 7 deletions
diff --git a/clang/test/CXX/drs/dr3xx.cpp b/clang/test/CXX/drs/dr3xx.cpp index 62cf21494a5..cea4d64e7eb 100644 --- a/clang/test/CXX/drs/dr3xx.cpp +++ b/clang/test/CXX/drs/dr3xx.cpp @@ -1219,7 +1219,7 @@ namespace dr391 { // dr391: yes c++11 namespace dr395 { // dr395: yes struct S { - template <typename T, int N>(&operator T())[N]; // expected-error {{must use a typedef}} + template <typename T, int N>(&operator T())[N]; // expected-error {{cannot specify any part of a return type}} template <typename T, int N> operator(T (&)[N])(); // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error +{{}} template <typename T> operator T *() const { return 0; } template <typename T, typename U> operator T U::*() const { return 0; } diff --git a/clang/test/FixIt/fixit.cpp b/clang/test/FixIt/fixit.cpp index 20b5b52c112..585c216f90d 100644 --- a/clang/test/FixIt/fixit.cpp +++ b/clang/test/FixIt/fixit.cpp @@ -381,3 +381,9 @@ struct H : A // expected-error{{expected '{' after base class list}} }; #endif } + +struct conversion_operator { + conversion_operator::* const operator int(); // expected-error {{put the complete type after 'operator'}} + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:32}:"" + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:44-[[@LINE-2]]:44}:" conversion_operator::* const" +}; 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}} + } + }; +}; |