aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2012-09-07 20:17:43 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2012-09-07 20:17:43 +0000
commite4394af56897939d2f47827330f75838fe038b23 (patch)
treee9060a220ebee364879e45a50e48228fa0c33ab1 /gcc/cp/parser.c
parentc294eb47b25bcf24bacfbcdecedda5651124f54c (diff)
downloadgcc-e4394af56897939d2f47827330f75838fe038b23.zip
gcc-e4394af56897939d2f47827330f75838fe038b23.tar.gz
gcc-e4394af56897939d2f47827330f75838fe038b23.tar.bz2
pt.c (num_template_headers_for_class): Rework per the code inline in cp_parser_check_declarator_template_parameters.
2012-09-07 Paolo Carlini <paolo.carlini@oracle.com> * pt.c (num_template_headers_for_class): Rework per the code inline in cp_parser_check_declarator_template_parameters. * parser.c (cp_parser_check_declarator_template_parameters): Use num_template_headers_for_class. From-SVN: r191082
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c56
1 files changed, 13 insertions, 43 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 60ba380..327ad0b 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -20670,54 +20670,24 @@ cp_parser_check_declarator_template_parameters (cp_parser* parser,
cp_declarator *declarator,
location_t declarator_location)
{
- unsigned num_templates;
-
- /* We haven't seen any classes that involve template parameters yet. */
- num_templates = 0;
-
switch (declarator->kind)
{
case cdk_id:
- if (declarator->u.id.qualifying_scope)
- {
- tree scope;
-
- scope = declarator->u.id.qualifying_scope;
-
- while (scope && CLASS_TYPE_P (scope))
- {
- /* You're supposed to have one `template <...>'
- for every template class, but you don't need one
- for a full specialization. For example:
-
- template <class T> struct S{};
- template <> struct S<int> { void f(); };
- void S<int>::f () {}
-
- is correct; there shouldn't be a `template <>' for
- the definition of `S<int>::f'. */
- if (!CLASSTYPE_TEMPLATE_INFO (scope))
- /* If SCOPE does not have template information of any
- kind, then it is not a template, nor is it nested
- within a template. */
- break;
- if (explicit_class_specialization_p (scope))
- break;
- if (PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (scope)))
- ++num_templates;
-
- scope = TYPE_CONTEXT (scope);
- }
- }
- else if (TREE_CODE (declarator->u.id.unqualified_name)
- == TEMPLATE_ID_EXPR)
- /* If the DECLARATOR has the form `X<y>' then it uses one
- additional level of template parameters. */
- ++num_templates;
+ {
+ unsigned num_templates = 0;
+ tree scope = declarator->u.id.qualifying_scope;
- return cp_parser_check_template_parameters
- (parser, num_templates, declarator_location, declarator);
+ if (scope)
+ num_templates = num_template_headers_for_class (scope);
+ else if (TREE_CODE (declarator->u.id.unqualified_name)
+ == TEMPLATE_ID_EXPR)
+ /* If the DECLARATOR has the form `X<y>' then it uses one
+ additional level of template parameters. */
+ ++num_templates;
+ return cp_parser_check_template_parameters
+ (parser, num_templates, declarator_location, declarator);
+ }
case cdk_function:
case cdk_array: