Commit 9c7b2b0b by Jason Merrill Committed by Jason Merrill

PR c++/92576 - redeclaration of variable template.

The variable templates patch way back when forgot to add handling here.  The
simplest answer seems to be recursing to the underlying declaration.

	* decl.c (redeclaration_error_message): Recurse for variable
	templates.

From-SVN: r279472
parent 490a091f
2019-12-17 Jason Merrill <jason@redhat.com>
PR c++/92576 - redeclaration of variable template.
* decl.c (redeclaration_error_message): Recurse for variable
templates.
2019-12-17 Jason Merrill <jason@redhat.com>
* name-lookup.c (get_std_name_hint): Add std::byte.
2019-12-17 Jakub Jelinek <jakub@redhat.com>
......
......@@ -2977,20 +2977,14 @@ redeclaration_error_message (tree newdecl, tree olddecl)
{
tree nt, ot;
if (TREE_CODE (DECL_TEMPLATE_RESULT (newdecl)) == TYPE_DECL)
{
if (COMPLETE_TYPE_P (TREE_TYPE (newdecl))
&& COMPLETE_TYPE_P (TREE_TYPE (olddecl)))
return G_("redefinition of %q#D");
return NULL;
}
if (TREE_CODE (DECL_TEMPLATE_RESULT (newdecl)) == CONCEPT_DECL)
return G_("redefinition of %q#D");
if (TREE_CODE (DECL_TEMPLATE_RESULT (newdecl)) != FUNCTION_DECL
|| (DECL_TEMPLATE_RESULT (newdecl)
== DECL_TEMPLATE_RESULT (olddecl)))
if (TREE_CODE (DECL_TEMPLATE_RESULT (newdecl)) != FUNCTION_DECL)
return redeclaration_error_message (DECL_TEMPLATE_RESULT (newdecl),
DECL_TEMPLATE_RESULT (olddecl));
if (DECL_TEMPLATE_RESULT (newdecl) == DECL_TEMPLATE_RESULT (olddecl))
return NULL;
nt = DECL_TEMPLATE_RESULT (newdecl);
......
......@@ -4,4 +4,4 @@ template<typename T>
bool V1 = true;
template<typename T>
bool V1<int> = false; // { dg-error "primary template|not deducible" }
bool V1<int> = false; // { dg-error "primary template|redefinition|not deducible" }
// PR c++/84255
// { dg-do compile { target c++14 } }
template<typename T> constexpr int var;
template<typename T> constexpr int var = 1; // { dg-error "redefinition" }
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