Skip to content
Snippets Groups Projects
Commit 19ac327d authored by Jason Merrill's avatar Jason Merrill
Browse files

c++: variable partial spec redeclaration [PR113612]

If register_specialization finds a previous declaration and throws the new
one away, we shouldn't still add the new one to
DECL_TEMPLATE_SPECIALIZATIONS.

	PR c++/113612

gcc/cp/ChangeLog:

	* pt.cc (process_partial_specialization): Return early
	on redeclaration.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/var-templ85.C: New test.
parent 7eac19be
No related branches found
No related tags found
No related merge requests found
...@@ -5417,9 +5417,14 @@ process_partial_specialization (tree decl) ...@@ -5417,9 +5417,14 @@ process_partial_specialization (tree decl)
} }
   
if (VAR_P (decl)) if (VAR_P (decl))
/* We didn't register this in check_explicit_specialization so we could {
wait until the constraints were set. */ /* We didn't register this in check_explicit_specialization so we could
decl = register_specialization (decl, maintmpl, specargs, false, 0); wait until the constraints were set. */
tree reg = register_specialization (decl, maintmpl, specargs, false, 0);
if (reg != decl)
/* Redeclaration. */
return reg;
}
else else
associate_classtype_constraints (type); associate_classtype_constraints (type);
   
......
// PR c++/113612
// { dg-do compile { target c++14 } }
template <typename T> T t;
template <typename T> extern T *t<T *>;
template <typename T> T *t<T *> = t<int>;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment