2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-02-10 07:23:08 +08:00
|
|
|
template<typename T,
|
|
|
|
int I,
|
|
|
|
template<typename> class TT>
|
2010-04-09 05:04:54 +08:00
|
|
|
class A; // expected-note 3 {{template is declared here}}
|
2009-02-10 07:23:08 +08:00
|
|
|
|
|
|
|
template<typename> class X;
|
|
|
|
|
|
|
|
A<int, 0, X> * a1;
|
|
|
|
|
Implement parsing of nested-name-specifiers that involve template-ids, e.g.,
std::vector<int>::allocator_type
When we parse a template-id that names a type, it will become either a
template-id annotation (which is a parsed representation of a
template-id that has not yet been through semantic analysis) or a
typename annotation (where semantic analysis has resolved the
template-id to an actual type), depending on the context. We only
produce a type in contexts where we know that we only need type
information, e.g., in a type specifier. Otherwise, we create a
template-id annotation that can later be "upgraded" by transforming it
into a typename annotation when the parser needs a type. This occurs,
for example, when we've parsed "std::vector<int>" above and then see
the '::' after it. However, it means that when writing something like
this:
template<> class Outer::Inner<int> { ... };
We have two tokens to represent Outer::Inner<int>: one token for the
nested name specifier Outer::, and one template-id annotation token
for Inner<int>, which will be passed to semantic analysis to define
the class template specialization.
Most of the churn in the template tests in this patch come from an
improvement in our error recovery from ill-formed template-ids.
llvm-svn: 65467
2009-02-26 03:37:18 +08:00
|
|
|
A<float, 1, X, double> *a2; // expected-error{{too many template arguments for class template 'A'}}
|
|
|
|
A<float, 1> *a3; // expected-error{{too few template arguments for class template 'A'}}
|
2017-01-27 04:40:47 +08:00
|
|
|
A a4; // expected-error{{use of class template 'A' requires template arguments}}
|
2010-02-26 16:45:28 +08:00
|
|
|
|
|
|
|
namespace test0 {
|
|
|
|
template <class t> class foo {};
|
|
|
|
template <class t> class bar {
|
|
|
|
bar(::test0::foo<tee> *ptr) {} // FIXME(redundant): expected-error 2 {{use of undeclared identifier 'tee'}}
|
|
|
|
};
|
|
|
|
}
|