Commit 802813ea by Jason Merrill Committed by Jason Merrill

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
parent ab7b72e1
2019-02-18 Jason Merrill <jason@redhat.com> 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. Improve duplicate [[likely]] diagnostic.
* parser.c (cp_parser_statement): Make attrs_loc a range. Pass it * parser.c (cp_parser_statement): Make attrs_loc a range. Pass it
to process_stmt_hotness_attribute. to process_stmt_hotness_attribute.
......
...@@ -2849,7 +2849,7 @@ check_explicit_specialization (tree declarator, ...@@ -2849,7 +2849,7 @@ check_explicit_specialization (tree declarator,
/* This case handles bogus declarations like template <> /* This case handles bogus declarations like template <>
template <class T> void f<int>(); */ 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", error ("template-id %qD in declaration of primary template",
declarator); declarator);
else if (variable_template_p (TREE_OPERAND (declarator, 0))) else if (variable_template_p (TREE_OPERAND (declarator, 0)))
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
#include <stdio.h> #include <stdio.h>
template <int n1> 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; return (double) n1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment