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
This commit is contained in:
Jason Merrill 2019-02-18 16:35:48 -05:00 committed by Jason Merrill
parent ab7b72e100
commit 802813eab9
3 changed files with 6 additions and 2 deletions

View file

@ -1,5 +1,8 @@
2019-02-18 Jason Merrill <jason@redhat.com>
* 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.

View file

@ -2849,7 +2849,7 @@ check_explicit_specialization (tree declarator,
/* This case handles bogus declarations like template <>
template <class T> void f<int>(); */
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)))

View file

@ -2,7 +2,8 @@
#include <stdio.h>
template <int n1>
double val <int> () // { dg-error "" } bogus code
double val <int> () // { dg-error "expected" "" { target c++17_down } } bogus code
// { dg-error "template-id .val<int>. in declaration of primary template" "" { target c++2a } .-1 }
{
return (double) n1;
}