Commit 3579964b by Jason Merrill Committed by Jason Merrill

pt.c (fn_type_unification): Push tinst level around type_unification_real if we aren't explaining.

gcc/cp/
	* pt.c (fn_type_unification): Push tinst level around
	type_unification_real if we aren't explaining.
	* cp-tree.h (TFF_NO_TEMPLATE_BINDINGS): New.
	* error.c (dump_function_decl): Respect it.
	(subst_to_string): Pass it.
libstdc++-v3/
	* testsuite/lib/prune.exp (libstdc++-dg-prune): Also ignore "In
	substitution" lines.

From-SVN: r198161
parent 80f7a782
2013-04-22 Jason Merrill <jason@redhat.com> 2013-04-22 Jason Merrill <jason@redhat.com>
* pt.c (fn_type_unification): Push tinst level around
type_unification_real if we aren't explaining.
* cp-tree.h (TFF_NO_TEMPLATE_BINDINGS): New.
* error.c (dump_function_decl): Respect it.
(subst_to_string): Pass it.
PR c++/48665 PR c++/48665
* rtti.c (get_typeid): Diagnose qualified function type. * rtti.c (get_typeid): Diagnose qualified function type.
* pt.c (tsubst) [POINTER_TYPE]: Likewise. * pt.c (tsubst) [POINTER_TYPE]: Likewise.
......
...@@ -4636,7 +4636,9 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG }; ...@@ -4636,7 +4636,9 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG };
TFF_UNQUALIFIED_NAME: do not print the qualifying scope of the TFF_UNQUALIFIED_NAME: do not print the qualifying scope of the
top-level entity. top-level entity.
TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS: do not omit template arguments TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS: do not omit template arguments
identical to their defaults. */ identical to their defaults.
TFF_NO_TEMPLATE_BINDINGS: do not print information about the template
arguments for a function template specialization. */
#define TFF_PLAIN_IDENTIFIER (0) #define TFF_PLAIN_IDENTIFIER (0)
#define TFF_SCOPE (1) #define TFF_SCOPE (1)
...@@ -4652,6 +4654,7 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG }; ...@@ -4652,6 +4654,7 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG };
#define TFF_NO_FUNCTION_ARGUMENTS (1 << 10) #define TFF_NO_FUNCTION_ARGUMENTS (1 << 10)
#define TFF_UNQUALIFIED_NAME (1 << 11) #define TFF_UNQUALIFIED_NAME (1 << 11)
#define TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS (1 << 12) #define TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS (1 << 12)
#define TFF_NO_TEMPLATE_BINDINGS (1 << 13)
/* Returns the TEMPLATE_DECL associated to a TEMPLATE_TEMPLATE_PARM /* Returns the TEMPLATE_DECL associated to a TEMPLATE_TEMPLATE_PARM
node. */ node. */
......
...@@ -1451,7 +1451,8 @@ dump_function_decl (tree t, int flags) ...@@ -1451,7 +1451,8 @@ dump_function_decl (tree t, int flags)
dump_type_suffix (TREE_TYPE (fntype), flags); dump_type_suffix (TREE_TYPE (fntype), flags);
/* If T is a template instantiation, dump the parameter binding. */ /* If T is a template instantiation, dump the parameter binding. */
if (template_parms != NULL_TREE && template_args != NULL_TREE) if (template_parms != NULL_TREE && template_args != NULL_TREE
&& !(flags & TFF_NO_TEMPLATE_BINDINGS))
{ {
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (cxx_pp);
pp_cxx_left_bracket (cxx_pp); pp_cxx_left_bracket (cxx_pp);
...@@ -2889,7 +2890,8 @@ subst_to_string (tree p) ...@@ -2889,7 +2890,8 @@ subst_to_string (tree p)
tree decl = TREE_PURPOSE (p); tree decl = TREE_PURPOSE (p);
tree targs = TREE_VALUE (p); tree targs = TREE_VALUE (p);
tree tparms = DECL_TEMPLATE_PARMS (decl); tree tparms = DECL_TEMPLATE_PARMS (decl);
int flags = TFF_DECL_SPECIFIERS|TFF_TEMPLATE_HEADER; int flags = (TFF_DECL_SPECIFIERS|TFF_TEMPLATE_HEADER
|TFF_NO_TEMPLATE_BINDINGS);
if (p == NULL_TREE) if (p == NULL_TREE)
return ""; return "";
......
...@@ -15125,9 +15125,21 @@ fn_type_unification (tree fn, ...@@ -15125,9 +15125,21 @@ fn_type_unification (tree fn,
callers must be ready to deal with unification failures in any callers must be ready to deal with unification failures in any
event. */ event. */
TREE_VALUE (tinst) = targs;
/* If we aren't explaining yet, push tinst context so we can see where
any errors (e.g. from class instantiations triggered by instantiation
of default template arguments) come from. If we are explaining, this
context is redundant. */
if (!explain_p && !push_tinst_level (tinst))
{
excessive_deduction_depth = true;
goto fail;
}
ok = !type_unification_real (DECL_INNERMOST_TEMPLATE_PARMS (fn), ok = !type_unification_real (DECL_INNERMOST_TEMPLATE_PARMS (fn),
targs, parms, args, nargs, /*subr=*/0, targs, parms, args, nargs, /*subr=*/0,
strict, flags, explain_p); strict, flags, explain_p);
if (!explain_p)
pop_tinst_level ();
if (!ok) if (!ok)
goto fail; goto fail;
......
// Only print template subst context when it isn't redundant.
// { dg-require-effective-target c++11 }
// { dg-prune-output "error" }
template<class T> struct A { typedef typename T::type type; };
template <class T, class U = typename A<T>::type>
void f(T);
template <class T, class U = typename T::type>
void g(T);
int main()
{
f(1); // { dg-message "required from here" }
g(1); // { dg-bogus "required from here" }
}
2013-04-22 Jason Merrill <jason@redhat.com> 2013-04-22 Jason Merrill <jason@redhat.com>
* testsuite/lib/prune.exp (libstdc++-dg-prune): Also ignore "In
substitution" lines.
* testsuite/20_util/is_assignable/value.cc: Comment out tests involving * testsuite/20_util/is_assignable/value.cc: Comment out tests involving
function-cv-quals. function-cv-quals.
* testsuite/20_util/is_constructible/value-2.cc: Likewise. * testsuite/20_util/is_constructible/value-2.cc: Likewise.
......
...@@ -42,7 +42,7 @@ proc libstdc++-dg-prune { system text } { ...@@ -42,7 +42,7 @@ proc libstdc++-dg-prune { system text } {
# Remove parts of warnings that refer to location of previous # Remove parts of warnings that refer to location of previous
# definitions, etc as these confuse dejagnu # definitions, etc as these confuse dejagnu
regsub -all "(^|\n)(\[^\n\]*: )?In ((static member |lambda )?function|member|method|(copy )?constructor|destructor|instantiation|program|subroutine|block-data)\[^\n\]*" $text "" text regsub -all "(^|\n)(\[^\n\]*: )?In ((static member |lambda )?function|member|method|(copy )?constructor|destructor|instantiation|substitution|program|subroutine|block-data)\[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*(: )?At (top level|global scope):\[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*(: )?At (top level|global scope):\[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*: (recursively )?required \[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*: (recursively )?required \[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*: . skipping \[0-9\]* instantiation contexts \[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*: . skipping \[0-9\]* instantiation contexts \[^\n\]*" $text "" text
......
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