summaryrefslogtreecommitdiffstats
path: root/test/Parser/cxx1z-class-template-argument-deduction.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-01-30 04:38:28 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-01-30 04:38:28 +0000
commita20c033fff75dd646149ff39536609b795eab81f (patch)
treef2877a6394bf2f2f8cb241a4b6cca5d1d6fa4917 /test/Parser/cxx1z-class-template-argument-deduction.cpp
parentd3d136e37c04ee173b3298991c98474471d05412 (diff)
Towards P0091R3: parsing support for class template argument deduction in typename-specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293455 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser/cxx1z-class-template-argument-deduction.cpp')
-rw-r--r--test/Parser/cxx1z-class-template-argument-deduction.cpp59
1 files changed, 58 insertions, 1 deletions
diff --git a/test/Parser/cxx1z-class-template-argument-deduction.cpp b/test/Parser/cxx1z-class-template-argument-deduction.cpp
index e53d64f2ed..65b1105d34 100644
--- a/test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ b/test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -verify %s
-template<typename T> struct A {}; // expected-note 31{{declared here}}
+template<typename T> struct A {}; // expected-note 35{{declared here}}
// Make sure we still correctly parse cases where a template can appear without arguments.
namespace template_template_arg {
@@ -101,6 +101,8 @@ namespace expr {
(void)reinterpret_cast<A*>(&n); // expected-error{{requires template arguments; argument deduction not allowed here}}
(void)const_cast<A>(n); // expected-error{{requires template arguments; argument deduction not allowed here}}
(void)*(A*)(&n); // expected-error{{requires template arguments; argument deduction not allowed here}}
+ (void)(A)(n); // expected-error{{requires template arguments; argument deduction not allowed here}}
+ (void)(A){n}; // expected-error{{requires template arguments; argument deduction not allowed here}}
(void)A(n); // expected-error {{not yet supported}}
(void)A{n}; // expected-error {{not yet supported}}
@@ -121,6 +123,7 @@ namespace decl {
A a; // expected-error {{requires an initializer}}
A b = 0; // expected-error {{not yet supported}}
+ const A c = 0; // expected-error {{not yet supported}}
A (parens) = 0; // expected-error {{cannot use parentheses when declaring variable with deduced class template specialization type}}
A *p = 0; // expected-error {{cannot form pointer to deduced class template specialization type}}
A &r = *p; // expected-error {{cannot form reference to deduced class template specialization type}}
@@ -129,3 +132,57 @@ namespace decl {
A (*fp)() = 0; // expected-error {{cannot form function returning deduced class template specialization type}}
A [x, y] = 0; // expected-error {{cannot be declared with type 'A'}} expected-error {{not yet supported}}
}
+
+namespace typename_specifier {
+ struct F {};
+
+ void e() {
+ (void) typename ::A(0); // expected-error {{not yet supported}}
+ (void) typename ::A{0}; // expected-error {{not yet supported}}
+ new typename ::A(0); // expected-error {{not yet supported}}
+ new typename ::A{0}; // expected-error {{not yet supported}}
+ typename ::A a = 0; // expected-error {{not yet supported}}
+ const typename ::A b = 0; // expected-error {{not yet supported}}
+ if (typename ::A a = 0) {} // expected-error {{not yet supported}}
+ for (typename ::A a = 0; typename ::A b = 0; /**/) {} // expected-error 2{{not yet supported}}
+
+ (void)(typename ::A)(0); // expected-error{{requires template arguments; argument deduction not allowed here}}
+ (void)(typename ::A){0}; // expected-error{{requires template arguments; argument deduction not allowed here}}
+ }
+ typename ::A a = 0; // expected-error {{not yet supported}}
+ const typename ::A b = 0; // expected-error {{not yet supported}}
+ typename ::A (parens) = 0; // expected-error {{cannot use parentheses when declaring variable with deduced class template specialization type}}
+ typename ::A *p = 0; // expected-error {{cannot form pointer to deduced class template specialization type}}
+ typename ::A &r = *p; // expected-error {{cannot form reference to deduced class template specialization type}}
+ typename ::A arr[3] = 0; // expected-error {{cannot form array of deduced class template specialization type}}
+ typename ::A F::*pm = 0; // expected-error {{cannot form pointer to deduced class template specialization type}}
+ typename ::A (*fp)() = 0; // expected-error {{cannot form function returning deduced class template specialization type}}
+ typename ::A [x, y] = 0; // expected-error {{cannot be declared with type 'typename ::A'}} expected-error {{not yet supported}}
+
+ struct X { template<typename T> struct A {}; }; // expected-note 8{{template}}
+
+ template<typename T> void f() {
+ (void) typename T::A(0); // expected-error {{not yet supported}}
+ (void) typename T::A{0}; // expected-error {{not yet supported}}
+ new typename T::A(0); // expected-error {{not yet supported}}
+ new typename T::A{0}; // expected-error {{not yet supported}}
+ typename T::A a = 0; // expected-error {{not yet supported}}
+ const typename T::A b = 0; // expected-error {{not yet supported}}
+ if (typename T::A a = 0) {} // expected-error {{not yet supported}}
+ for (typename T::A a = 0; typename T::A b = 0; /**/) {} // expected-error 2{{not yet supported}}
+
+ {(void)(typename T::A)(0);} // expected-error{{refers to class template member}}
+ {(void)(typename T::A){0};} // expected-error{{refers to class template member}}
+ {typename T::A (parens) = 0;} // expected-error {{refers to class template member in 'typename_specifier::X'; argument deduction not allowed here}}
+ {typename T::A *p = 0;} // expected-error {{refers to class template member}}
+ {typename T::A &r = *p;} // expected-error {{refers to class template member}}
+ {typename T::A arr[3] = 0;} // expected-error {{refers to class template member}}
+ {typename T::A F::*pm = 0;} // expected-error {{refers to class template member}}
+ {typename T::A (*fp)() = 0;} // expected-error {{refers to class template member}}
+ {typename T::A [x, y] = 0;} // expected-error {{cannot be declared with type 'typename T::A'}} expected-error {{not yet supported}}
+ }
+ template void f<X>(); // expected-note {{instantiation of}}
+
+ template<typename T> void g(typename T::A = 0); // expected-note {{refers to class template member}}
+ void h() { g<X>(); } // expected-error {{no matching function}}
+}