From 802813eab9ab6f05a7a81161f372ac5be0b120a4 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 18 Feb 2019 16:35:48 -0500 Subject: [PATCH] Improve diagnostic for redundant template arguments in declaration. * pt.c (check_explicit_specialization): If the declarator is a template-id, only check whether the arguments are dependent. From-SVN: r268997 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/pt.c | 2 +- gcc/testsuite/g++.old-deja/g++.robertl/eb82.C | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d820e941093..33a1ca24c9f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2019-02-18 Jason Merrill + * pt.c (check_explicit_specialization): If the declarator is a + template-id, only check whether the arguments are dependent. + Improve duplicate [[likely]] diagnostic. * parser.c (cp_parser_statement): Make attrs_loc a range. Pass it to process_stmt_hotness_attribute. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 48cbf3d9892..d8be92ddca4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2849,7 +2849,7 @@ check_explicit_specialization (tree declarator, /* This case handles bogus declarations like template <> template void f(); */ - if (!uses_template_parms (declarator)) + if (!uses_template_parms (TREE_OPERAND (declarator, 1))) error ("template-id %qD in declaration of primary template", declarator); else if (variable_template_p (TREE_OPERAND (declarator, 0))) diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb82.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb82.C index fc2bf7866fe..d4c5985cd8c 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb82.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb82.C @@ -2,7 +2,8 @@ #include template -double val () // { dg-error "" } bogus code +double val () // { dg-error "expected" "" { target c++17_down } } bogus code +// { dg-error "template-id .val. in declaration of primary template" "" { target c++2a } .-1 } { return (double) n1; } -- 2.30.2