diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-12-05 00:58:33 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-12-05 00:58:33 +0000 |
commit | d091dc179dbd1060029268043f0bad1d7a87fc00 (patch) | |
tree | e4c7be91cc07eaed2d2c62c52e5c65ee3a025ac8 /clang/test/SemaCXX/cxx11-user-defined-literals.cpp | |
parent | b9a69f6129735552d8d5caf32c5a1a30e934c1dc (diff) | |
download | bcm5719-llvm-d091dc179dbd1060029268043f0bad1d7a87fc00.tar.gz bcm5719-llvm-d091dc179dbd1060029268043f0bad1d7a87fc00.zip |
Reject template-ids containing literal-operator-ids that have a dependent
nested-name-specifier, rather than crashing. (In fact, reject all
literal-operator-ids that have a non-namespace nested-name-specifier). The
grammar doesn't allow these in some cases, and in other cases does allow them
but instantiation will always fail.
llvm-svn: 196443
Diffstat (limited to 'clang/test/SemaCXX/cxx11-user-defined-literals.cpp')
-rw-r--r-- | clang/test/SemaCXX/cxx11-user-defined-literals.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/cxx11-user-defined-literals.cpp b/clang/test/SemaCXX/cxx11-user-defined-literals.cpp index f8bbcd960fd..cb7796418ee 100644 --- a/clang/test/SemaCXX/cxx11-user-defined-literals.cpp +++ b/clang/test/SemaCXX/cxx11-user-defined-literals.cpp @@ -141,3 +141,27 @@ namespace PR14950 { int operator"" _b(); // expected-error {{no function template matches function template specialization}} int main() { return 0_b; } // expected-error {{no matching literal operator for call to 'operator "" _b'}} } + +namespace bad_names { + template<char...> int operator""_x(); + + template<typename T> void f() { + class T:: // expected-error {{anonymous class}} expected-warning {{does not declare anything}} + operator // expected-error {{expected identifier}} + ""_q<'a'>; + + T::template operator""_q<'a'>(); // expected-error {{non-namespace scope 'T::' cannot have a literal operator member}} expected-error +{{}} + T::template operator""_q<'a'>::X; // expected-error {{non-namespace scope 'T::' cannot have a literal operator member}} expected-error +{{}} + T::operator""_q<'a'>(); // expected-error {{non-namespace scope 'T::' cannot have a literal operator member}} expected-error +{{}} + typename T::template operator""_q<'a'> a; // expected-error {{non-namespace scope 'T::' cannot have a literal operator member}} expected-error +{{}} + typename T::operator""_q(""); // expected-error +{{}} expected-note {{to match}} + T::operator""_q(""); // expected-error {{non-namespace scope 'T::' cannot have a literal operator member}} + + bad_names::operator""_x<'a', 'b', 'c'>(); + }; + + struct S {}; + void g() { + S::operator""_q(); // expected-error {{non-namespace scope 'S::' cannot have a literal operator member}} + } +} |