re PR c++/48969 (ICE with -std=c++0x)

PR c++/48969
	PR c++/44175
gcc/c-family/
	* c-common.c (max_tinst_depth): Lower default to 900.
gcc/cp/
	* error.c (subst_to_string): New.
	(cp_printer): Use it for 'S'.
	(print_instantiation_partial_context_line): Handle subst context.
	* pt.c (push_tinst_level): Handle subst context.
	(deduction_tsubst_fntype): Don't track specific substitutions.
	Use push_tinst_level.

From-SVN: r174772
This commit is contained in:
Jason Merrill 2011-06-07 17:54:07 -04:00 committed by Jason Merrill
parent 783c26ae67
commit 3ff6097510
151 changed files with 452 additions and 355 deletions

View file

@ -1,5 +1,7 @@
2011-06-07 Jason Merrill <jason@redhat.com>
* c-common.c (max_tinst_depth): Lower default to 900.
* c-format.c (gcc_cxxdiag_char_table): Add 'S' format.
2011-06-07 Richard Guenther <rguenther@suse.de>

View file

@ -255,10 +255,13 @@ int flag_use_repository;
enum cxx_dialect cxx_dialect = cxx98;
/* Maximum template instantiation depth. This limit exists to limit the
time it takes to notice excessively recursive template instantiations;
the default value of 1024 is likely to be in the next C++ standard. */
time it takes to notice excessively recursive template instantiations.
int max_tinst_depth = 1024;
The default is lower than the 1024 recommended by the C++0x standard
because G++ runs out of stack before 1024 with highly recursive template
argument deduction substitution (g++.dg/cpp0x/enum11.C). */
int max_tinst_depth = 900;
/* The elements of `ridpointers' are identifier nodes for the reserved
type names and storage classes. It is indexed by a RID_... value. */

View file

@ -1,5 +1,14 @@
2011-06-07 Jason Merrill <jason@redhat.com>
PR c++/48969
PR c++/44175
* error.c (subst_to_string): New.
(cp_printer): Use it for 'S'.
(print_instantiation_partial_context_line): Handle subst context.
* pt.c (push_tinst_level): Handle subst context.
(deduction_tsubst_fntype): Don't track specific substitutions.
Use push_tinst_level.
* pt.c (deduction_tsubst_fntype): Use push_deduction_access_scope.
(fn_type_unification): Don't call push_deduction_access_scope here.

View file

@ -2665,6 +2665,32 @@ args_to_string (tree p, int verbose)
return pp_formatted_text (cxx_pp);
}
/* Pretty-print a deduction substitution (from deduction_tsubst_fntype). P
is a TREE_LIST with purpose the TEMPLATE_DECL, value the template
arguments. */
static const char *
subst_to_string (tree p)
{
tree decl = TREE_PURPOSE (p);
tree targs = TREE_VALUE (p);
tree tparms = DECL_TEMPLATE_PARMS (decl);
int flags = TFF_DECL_SPECIFIERS|TFF_TEMPLATE_HEADER;
if (p == NULL_TREE)
return "";
reinit_cxx_pp ();
dump_template_decl (TREE_PURPOSE (p), flags);
pp_cxx_whitespace (cxx_pp);
pp_cxx_left_bracket (cxx_pp);
pp_cxx_ws_string (cxx_pp, M_("with"));
pp_cxx_whitespace (cxx_pp);
dump_template_bindings (tparms, targs, NULL);
pp_cxx_right_bracket (cxx_pp);
return pp_formatted_text (cxx_pp);
}
static const char *
cv_to_string (tree p, int v)
{
@ -2888,38 +2914,34 @@ print_instantiation_partial_context_line (diagnostic_context *context,
expanded_location xloc;
xloc = expand_location (loc);
if (t != NULL)
if (context->show_column)
pp_verbatim (context->printer, _("%s:%d:%d: "),
xloc.file, xloc.line, xloc.column);
else
pp_verbatim (context->printer, _("%s:%d: "),
xloc.file, xloc.line);
if (t != NULL)
{
const char *str;
str = decl_as_string_translate (t->decl,
TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE);
if (context->show_column)
if (TREE_CODE (t->decl) == TREE_LIST)
pp_verbatim (context->printer,
recursive_p
? _("%s:%d:%d: recursively instantiated from %qs\n")
: _("%s:%d:%d: instantiated from %qs\n"),
xloc.file, xloc.line, xloc.column, str);
? _("recursively required by substitution of %qS\n")
: _("required by substitution of %qS\n"),
t->decl);
else
pp_verbatim (context->printer,
recursive_p
? _("%s:%d: recursively instantiated from %qs\n")
: _("%s:%d: recursively instantiated from %qs\n"),
xloc.file, xloc.line, str);
? _("recursively required from %q#D\n")
: _("required from %q#D\n"),
t->decl);
}
else
{
if (context->show_column)
pp_verbatim (context->printer,
recursive_p
? _("%s:%d:%d: recursively instantiated from here")
: _("%s:%d:%d: instantiated from here"),
xloc.file, xloc.line, xloc.column);
else
pp_verbatim (context->printer,
recursive_p
? _("%s:%d: recursively instantiated from here")
: _("%s:%d: instantiated from here"),
xloc.file, xloc.line);
pp_verbatim (context->printer,
recursive_p
? _("recursively required from here")
: _("required from here"));
}
}
@ -3093,6 +3115,7 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec,
case 'O': result = op_to_string (next_tcode); break;
case 'P': result = parm_to_string (next_int); break;
case 'Q': result = assop_to_string (next_tcode); break;
case 'S': result = subst_to_string (next_tree); break;
case 'T': result = type_to_string (next_tree, verbose); break;
case 'V': result = cv_to_string (next_tree, verbose); break;

View file

@ -7490,16 +7490,15 @@ push_tinst_level (tree d)
if (tinst_depth >= max_tinst_depth)
{
/* If the instantiation in question still has unbound template parms,
we don't really care if we can't instantiate it, so just return.
This happens with base instantiation for implicit `typename'. */
if (uses_template_parms (d))
return 0;
last_template_error_tick = tinst_level_tick;
error ("template instantiation depth exceeds maximum of %d (use "
"-ftemplate-depth= to increase the maximum) instantiating %qD",
max_tinst_depth, d);
if (TREE_CODE (d) == TREE_LIST)
error ("template instantiation depth exceeds maximum of %d (use "
"-ftemplate-depth= to increase the maximum) substituting %qS",
max_tinst_depth, d);
else
error ("template instantiation depth exceeds maximum of %d (use "
"-ftemplate-depth= to increase the maximum) instantiating %qD",
max_tinst_depth, d);
print_instantiation_context ();
@ -13594,11 +13593,6 @@ check_instantiated_args (tree tmpl, tree args, tsubst_flags_t complain)
return result;
}
DEF_VEC_O (spec_entry);
DEF_VEC_ALLOC_O (spec_entry,gc);
static GTY(()) VEC(spec_entry,gc) *current_deduction_vec;
static GTY((param_is (spec_entry))) htab_t current_deduction_htab;
/* In C++0x, it's possible to have a function template whose type depends
on itself recursively. This is most obvious with decltype, but can also
occur with enumeration scope (c++/48969). So we need to catch infinite
@ -13609,133 +13603,48 @@ static GTY((param_is (spec_entry))) htab_t current_deduction_htab;
f<N-1> across all integers, and returns error_mark_node for all the
substitutions back up to the initial one.
This is, of course, not reentrant.
Use of a VEC here is O(n^2) in the depth of function template argument
deduction substitution, but using a hash table creates a lot of constant
overhead for the typical case of very low depth. So to make the typical
case fast we start out with a VEC and switch to a hash table only if
depth gets to be significant; in one metaprogramming testcase, even at
depth 80 the overhead of the VEC relative to a hash table was only about
0.5% of compile time. */
This is, of course, not reentrant. */
static tree
deduction_tsubst_fntype (tree fn, tree targs)
{
static bool excessive_deduction_depth;
unsigned i;
spec_entry **slot;
spec_entry *p;
spec_entry elt;
tree r;
hashval_t hash;
static int deduction_depth;
location_t save_loc = input_location;
tree fntype = TREE_TYPE (fn);
tree tinst;
tree r;
/* We don't need to worry about this in C++98. */
if (cxx_dialect < cxx0x)
if (excessive_deduction_depth)
return error_mark_node;
tinst = build_tree_list (fn, targs);
if (!push_tinst_level (tinst))
{
push_deduction_access_scope (fn);
r = tsubst (fntype, targs, tf_none, NULL_TREE);
pop_deduction_access_scope (fn);
return r;
}
/* If we're seeing a lot of recursion, switch over to a hash table. The
constant 40 is fairly arbitrary. */
if (!current_deduction_htab
&& VEC_length (spec_entry, current_deduction_vec) > 40)
{
current_deduction_htab = htab_create_ggc (40*2, hash_specialization,
eq_specializations, ggc_free);
FOR_EACH_VEC_ELT (spec_entry, current_deduction_vec, i, p)
{
slot = (spec_entry **) htab_find_slot (current_deduction_htab,
p, INSERT);
*slot = ggc_alloc_spec_entry ();
**slot = *p;
}
VEC_free (spec_entry, gc, current_deduction_vec);
}
/* Now check everything in the vector, if any. */
FOR_EACH_VEC_ELT (spec_entry, current_deduction_vec, i, p)
if (p->tmpl == fn && comp_template_args (p->args, targs))
{
p->spec = error_mark_node;
return error_mark_node;
}
elt.tmpl = fn;
elt.args = targs;
elt.spec = NULL_TREE;
/* If we've created a hash table, look there. */
if (current_deduction_htab)
{
if (htab_elements (current_deduction_htab)
> (unsigned) max_tinst_depth)
{
/* Trying to recurse across all integers or some such. */
excessive_deduction_depth = true;
return error_mark_node;
}
hash = hash_specialization (&elt);
slot = (spec_entry **)
htab_find_slot_with_hash (current_deduction_htab, &elt, hash, INSERT);
if (*slot)
{
/* We already have an entry for this. */
(*slot)->spec = error_mark_node;
return error_mark_node;
}
else
{
/* Create a new entry. */
*slot = ggc_alloc_spec_entry ();
**slot = elt;
}
}
else
{
/* No hash table, so add it to the VEC. */
hash = 0;
VEC_safe_push (spec_entry, gc, current_deduction_vec, &elt);
excessive_deduction_depth = true;
ggc_free (tinst);
return error_mark_node;
}
input_location = DECL_SOURCE_LOCATION (fn);
++deduction_depth;
push_deduction_access_scope (fn);
r = tsubst (fntype, targs, tf_none, NULL_TREE);
pop_deduction_access_scope (fn);
--deduction_depth;
input_location = save_loc;
/* After doing the substitution, make sure we didn't hit it again. Note
that we might have switched to a hash table during tsubst. */
if (current_deduction_htab)
{
if (hash == 0)
hash = hash_specialization (&elt);
slot = (spec_entry **)
htab_find_slot_with_hash (current_deduction_htab, &elt, hash,
NO_INSERT);
if ((*slot)->spec == error_mark_node)
r = error_mark_node;
htab_clear_slot (current_deduction_htab, (void**)slot);
}
else
{
if (VEC_last (spec_entry, current_deduction_vec)->spec
== error_mark_node)
r = error_mark_node;
VEC_pop (spec_entry, current_deduction_vec);
}
if (excessive_deduction_depth)
{
r = error_mark_node;
if (htab_elements (current_deduction_htab) == 0)
if (deduction_depth == 0)
/* Reset once we're all the way out. */
excessive_deduction_depth = false;
}
pop_tinst_level ();
ggc_free (tinst);
return r;
}
@ -19562,11 +19471,6 @@ print_template_statistics (void)
"%f collisions\n", (long) htab_size (type_specializations),
(long) htab_elements (type_specializations),
htab_collisions (type_specializations));
if (current_deduction_htab)
fprintf (stderr, "current_deduction_htab: size %ld, %ld elements, "
"%f collisions\n", (long) htab_size (current_deduction_htab),
(long) htab_elements (current_deduction_htab),
htab_collisions (current_deduction_htab));
}
#include "gt-cp-pt.h"

View file

@ -2069,7 +2069,8 @@ Set the maximum instantiation depth for template classes to @var{n}.
A limit on the template instantiation depth is needed to detect
endless recursions during template class instantiation. ANSI/ISO C++
conforming programs must not rely on a maximum depth greater than 17
(changed to 1024 in C++0x).
(changed to 1024 in C++0x). The default value is 900, as the compiler
can run out of stack space before hitting 1024 in some situations.
@item -fno-threadsafe-statics
@opindex fno-threadsafe-statics

View file

@ -1,3 +1,131 @@
2011-06-07 Jason Merrill <jason@redhat.com>
* lib/prune.exp: Look for "required" rather than "instantiated".
* g++.dg/abi/mangle11.C: Likewise.
* g++.dg/abi/mangle12.C: Likewise.
* g++.dg/abi/mangle17.C: Likewise.
* g++.dg/abi/mangle20-2.C: Likewise.
* g++.dg/abi/pragma-pack1.C: Likewise.
* g++.dg/cpp0x/decltype26.C: Likewise.
* g++.dg/cpp0x/decltype28.C: Likewise.
* g++.dg/cpp0x/decltype29.C: Likewise.
* g++.dg/cpp0x/enum11.C: Likewise.
* g++.dg/cpp0x/forw_enum8.C: Likewise.
* g++.dg/cpp0x/lambda/lambda-errloc2.C: Likewise.
* g++.dg/cpp0x/pr47416.C: Likewise.
* g++.dg/ext/case-range2.C: Likewise.
* g++.dg/ext/case-range3.C: Likewise.
* g++.dg/gomp/for-19.C: Likewise.
* g++.dg/gomp/pr37533.C: Likewise.
* g++.dg/gomp/pr38639.C: Likewise.
* g++.dg/gomp/tpl-parallel-2.C: Likewise.
* g++.dg/inherit/base3.C: Likewise.
* g++.dg/inherit/using6.C: Likewise.
* g++.dg/init/placement4.C: Likewise.
* g++.dg/init/reference3.C: Likewise.
* g++.dg/lookup/scoped6.C: Likewise.
* g++.dg/lookup/using7.C: Likewise.
* g++.dg/other/abstract1.C: Likewise.
* g++.dg/other/error10.C: Likewise.
* g++.dg/other/error5.C: Likewise.
* g++.dg/other/field1.C: Likewise.
* g++.dg/other/offsetof5.C: Likewise.
* g++.dg/parse/bitfield2.C: Likewise.
* g++.dg/parse/constant4.C: Likewise.
* g++.dg/parse/crash20.C: Likewise.
* g++.dg/parse/invalid-op1.C: Likewise.
* g++.dg/parse/non-dependent2.C: Likewise.
* g++.dg/parse/template18.C: Likewise.
* g++.dg/tc1/dr152.C: Likewise.
* g++.dg/tc1/dr166.C: Likewise.
* g++.dg/tc1/dr176.C: Likewise.
* g++.dg/tc1/dr213.C: Likewise.
* g++.dg/template/access11.C: Likewise.
* g++.dg/template/access2.C: Likewise.
* g++.dg/template/access3.C: Likewise.
* g++.dg/template/access7.C: Likewise.
* g++.dg/template/arg7.C: Likewise.
* g++.dg/template/cond2.C: Likewise.
* g++.dg/template/crash13.C: Likewise.
* g++.dg/template/crash40.C: Likewise.
* g++.dg/template/crash7.C: Likewise.
* g++.dg/template/crash84.C: Likewise.
* g++.dg/template/ctor5.C: Likewise.
* g++.dg/template/defarg13.C: Likewise.
* g++.dg/template/defarg14.C: Likewise.
* g++.dg/template/dtor7.C: Likewise.
* g++.dg/template/eh2.C: Likewise.
* g++.dg/template/error2.C: Likewise.
* g++.dg/template/error43.C: Likewise.
* g++.dg/template/friend32.C: Likewise.
* g++.dg/template/injected1.C: Likewise.
* g++.dg/template/instantiate1.C: Likewise.
* g++.dg/template/instantiate3.C: Likewise.
* g++.dg/template/instantiate5.C: Likewise.
* g++.dg/template/instantiate7.C: Likewise.
* g++.dg/template/local6.C: Likewise.
* g++.dg/template/lookup2.C: Likewise.
* g++.dg/template/member5.C: Likewise.
* g++.dg/template/memfriend15.C: Likewise.
* g++.dg/template/memfriend16.C: Likewise.
* g++.dg/template/memfriend17.C: Likewise.
* g++.dg/template/memfriend7.C: Likewise.
* g++.dg/template/meminit1.C: Likewise.
* g++.dg/template/nested3.C: Likewise.
* g++.dg/template/non-type-template-argument-1.C: Likewise.
* g++.dg/template/nontype12.C: Likewise.
* g++.dg/template/nontype13.C: Likewise.
* g++.dg/template/nontype6.C: Likewise.
* g++.dg/template/pr23510.C: Likewise.
* g++.dg/template/pr35240.C: Likewise.
* g++.dg/template/ptrmem15.C: Likewise.
* g++.dg/template/ptrmem6.C: Likewise.
* g++.dg/template/qualified-id1.C: Likewise.
* g++.dg/template/qualttp20.C: Likewise.
* g++.dg/template/qualttp3.C: Likewise.
* g++.dg/template/qualttp4.C: Likewise.
* g++.dg/template/qualttp5.C: Likewise.
* g++.dg/template/qualttp6.C: Likewise.
* g++.dg/template/qualttp7.C: Likewise.
* g++.dg/template/qualttp8.C: Likewise.
* g++.dg/template/recurse.C: Likewise.
* g++.dg/template/recurse2.C: Likewise.
* g++.dg/template/ref5.C: Likewise.
* g++.dg/template/scope2.C: Likewise.
* g++.dg/template/sfinae10.C: Likewise.
* g++.dg/template/sfinae3.C: Likewise.
* g++.dg/template/sizeof3.C: Likewise.
* g++.dg/template/static9.C: Likewise.
* g++.dg/template/template-id-2.C: Likewise.
* g++.dg/template/typedef13.C: Likewise.
* g++.dg/template/typename4.C: Likewise.
* g++.dg/template/using14.C: Likewise.
* g++.dg/template/using2.C: Likewise.
* g++.dg/template/warn1.C: Likewise.
* g++.dg/warn/Wparentheses-13.C: Likewise.
* g++.dg/warn/Wparentheses-15.C: Likewise.
* g++.dg/warn/Wparentheses-16.C: Likewise.
* g++.dg/warn/Wparentheses-17.C: Likewise.
* g++.dg/warn/Wparentheses-18.C: Likewise.
* g++.dg/warn/Wparentheses-19.C: Likewise.
* g++.dg/warn/Wparentheses-20.C: Likewise.
* g++.dg/warn/Wparentheses-23.C: Likewise.
* g++.dg/warn/Wstrict-aliasing-3.C: Likewise.
* g++.dg/warn/noeffect2.C: Likewise.
* g++.dg/warn/noeffect4.C: Likewise.
* g++.dg/warn/pr8570.C: Likewise.
* g++.old-deja/g++.brendan/init2.C: Likewise.
* g++.old-deja/g++.eh/spec6.C: Likewise.
* g++.old-deja/g++.pt/crash10.C: Likewise.
* g++.old-deja/g++.pt/crash36.C: Likewise.
* g++.old-deja/g++.pt/derived3.C: Likewise.
* g++.old-deja/g++.pt/error2.C: Likewise.
* g++.old-deja/g++.pt/explicit70.C: Likewise.
* g++.old-deja/g++.pt/infinite1.C: Likewise.
* g++.old-deja/g++.pt/memtemp89.C: Likewise.
* g++.old-deja/g++.pt/overload7.C: Likewise.
* g++.old-deja/g++.pt/vaarg3.C: Likewise.
2011-06-07 Nicola Pero <nicola.pero@meta-innovation.com>
Iain Sandoe <iains@gcc.gnu.org>

View file

@ -7,4 +7,4 @@ struct S {
typedef int X;
};
template void f<S> (int); // { dg-message "instantiated" }
template void f<S> (int); // { dg-message "required" }

View file

@ -8,4 +8,4 @@ struct S {
typedef int X;
};
template void f<S> (int); // { dg-message "instantiated" }
template void f<S> (int); // { dg-message "required" }

View file

@ -5,7 +5,7 @@ enum E { e = 3 };
template <int I> struct S {};
template <int I> void f (S<I + e + int (3.7)>) {} // { dg-warning "mangle" }
template void f<7>(S<7 + e + int (3.7)>); // { dg-message "instantiated" }
template void f<7>(S<7 + e + int (3.7)>); // { dg-message "required" }
template <int I> void g (S<I + e + int (3.7)>) {} // { dg-warning "mangle" }
template void g<7>(S<7 + e + int (3.7)>); // { dg-message "instantiated" }
template void g<7>(S<7 + e + int (3.7)>); // { dg-message "required" }

View file

@ -10,7 +10,7 @@
template <int I> void f(int (*)[2]) {} // { dg-warning "mangled name" }
template <int I> void g(int (*)[I+2]) {}
template void f<1>(int (*)[2]); // { dg-message "instantiated" }
template void f<1>(int (*)[2]); // { dg-message "required" }
// { dg-final { scan-assembler "\n_?_Z1fILi1EEvPALi2E_i\[: \t\n\]" } }
template void g<1>(int (*)[3]);
// { dg-final { scan-assembler "\n_?_Z1gILi1EEvPAplT_Li2E_i\[: \t\n\]" } }

View file

@ -23,7 +23,7 @@ template struct T<int>; /* T<int> is instantiated here */
template int f<int>();
#pragma pack(4)
template struct T<float>; /* T<float> is instantiated here */
template struct T<float>; /* T<float> is required here */
template int f<double>();
int main()

View file

@ -3,7 +3,7 @@
struct A { };
template <class T>
decltype(f(T())) f(T t)
decltype(f(T())) f(T t) // { dg-error "depth" }
{
return f(t);
}

View file

@ -9,8 +9,8 @@ void ft (F f, typename enable_if<N!=0, int>::type) {}
template< class F, int N >
decltype(ft<F, N-1> (F(), 0))
ft (F f, typename enable_if<N==0, int>::type) {}
ft (F f, typename enable_if<N==0, int>::type) {} // { dg-error "depth" }
int main() {
ft<struct a*, 2> (0, 0);
ft<struct a*, 2> (0, 0); // { dg-message "from here" }
}

View file

@ -10,7 +10,7 @@ ft() {}
template<class F, int N>
decltype (ft<F> (F()))
ft() {}
ft() {} // { dg-error "depth" }
int main() {
ft<struct a*, 0>(); // { dg-error "no match" }

View file

@ -1,10 +1,14 @@
// PR c++/48969
// { dg-options -std=c++0x }
// { dg-options "-std=c++0x -ftemplate-depth=10" }
template<unsigned int N> struct Pair { };
struct Foo { enum { Mask = 1 }; } foo;
template<typename A, typename B> class Pair<A::Mask | B::Mask>
operator|(const A &, const B &)
operator|(const A &, const B &) // { dg-message "substitution" }
{ }
Pair<Foo::Mask> f = foo|foo;
Pair<Foo::Mask> f = foo|foo; // { dg-message "no match" }
// { dg-prune-output "note" }
// { dg-prune-output "here" }
// { dg-prune-output "instantiation depth" }

View file

@ -15,7 +15,7 @@ template<typename T> struct S2
enum E : int; // { dg-error "previous definition" }
enum E : T; // { dg-error "different underlying type" }
};
template struct S2<short>; // { dg-message "instantiated from here" }
template struct S2<short>; // { dg-message "required from here" }
//This error is diagnosed at compilation time
template<typename T> struct S3

View file

@ -15,5 +15,5 @@ void f()
int main()
{
f<A>(); // { dg-message "instantiated" }
f<A>(); // { dg-message "required" }
}

View file

@ -210,7 +210,7 @@ namespace boost
private:table table_;
public: unordered_map (size_type n = boost::unordered_detail::default_bucket_count,
hasher hf = hasher (), key_equal eql = key_equal (),
allocator_type a = allocator_type ()):table_ (n, hf, eql, a) // { dg-message "instantiated" }
allocator_type a = allocator_type ()):table_ (n, hf, eql, a) // { dg-message "required" }
{
}
};
@ -220,6 +220,6 @@ void
foo (const int &a)
{
typedef boost::unordered_map < std::string, int >Name2Port;
Name2Port b; // { dg-message "instantiated" }
Name2Port b; // { dg-message "required" }
std::make_pair (a, b);
}

View file

@ -22,6 +22,6 @@ int f (int i)
switch (i) {
case 1 ... 10: return i + 1; // { dg-error "first entry" }
case 3 ... 5 : return i + 3; // { dg-error "duplicate" }
default: return f2 (i); // { dg-message "instantiated" }
default: return f2 (i); // { dg-message "required" }
}
}

View file

@ -18,6 +18,6 @@ int f (int i)
{
switch (i) {
case 1 ... 10: return i + 1; // { dg-warning "non-standard" }
default: return f2 (i); // { dg-message "instantiated" }
default: return f2 (i); // { dg-message "required" }
}
}

View file

@ -34,8 +34,8 @@ f3 (void)
int
main (void)
{
f1 <int> (); // { dg-message "instantiated from here" }
f1 <int> (); // { dg-message "required from here" }
f2 <int> ();
f3 <const char *> ();
f3 <void *> (); // { dg-message "instantiated from here" }
f3 <void *> (); // { dg-message "required from here" }
}

View file

@ -43,8 +43,8 @@ f4 ()
void
bar ()
{
f1<0> (); // { dg-message "instantiated from here" }
f2<1> (); // { dg-message "instantiated from here" }
f3<int> (); // { dg-message "instantiated from here" }
f4<int> (); // { dg-message "instantiated from here" }
f1<0> (); // { dg-message "required from here" }
f2<1> (); // { dg-message "required from here" }
f3<int> (); // { dg-message "required from here" }
f4<int> (); // { dg-message "required from here" }
}

View file

@ -13,5 +13,5 @@ foo ()
void
bar ()
{
foo<0> (); // { dg-message "instantiated from here" }
foo<0> (); // { dg-message "required from here" }
}

View file

@ -17,4 +17,4 @@ void S<T>::test()
template struct S<int>;
template struct S<long>;
template struct S<float>; // { dg-message "instantiated from here" }
template struct S<float>; // { dg-message "required from here" }

View file

@ -5,4 +5,4 @@ template<typename T> struct A : T {}; // { dg-error "struct or class type" }
struct B;
A<void (B::*)()> a; // { dg-message "instantiated" }
A<void (B::*)()> a; // { dg-message "required" }

View file

@ -12,4 +12,4 @@ template <typename T> struct TPL : A
};
TPL<int> i;
TPL<float> j; // { dg-message "instantiated" }
TPL<float> j; // { dg-message "required" }

View file

@ -27,6 +27,6 @@ void operator delete(void *p,Pool<T>& pool)
int main ()
{
Pool<int> pool;
new (pool) A(); // { dg-message "instantiated" }
new (pool) A(); // { dg-message "required" }
return 0;
}

View file

@ -9,5 +9,5 @@ T f()
T a = T(); // { dg-error "value-initialization of reference" }
}
int &a = f<int&>(); // { dg-message "instantiated from here" }
int &a = f<int&>(); // { dg-message "required from here" }

View file

@ -10,7 +10,7 @@ public:
class Bar {
Foo<int> foo_;
public:
Bar() {} // { dg-message "instantiated" }
Bar() {} // { dg-message "required" }
};
template class Foo<int>;

View file

@ -9,4 +9,4 @@ template <typename T> struct B : A<T> // { dg-error "incomplete" }
// { dg-error "using" "using" { target *-*-* } 8 }
};
B<void> b; // { dg-message "instantiated" }
B<void> b; // { dg-message "required" }

View file

@ -35,7 +35,7 @@ template <class T> struct K {
T (*a)[2]; // { dg-error "abstract class type" }
};
template struct K<Abstract>; // { dg-message "instantiated" }
template struct K<Abstract>; // { dg-message "required" }

View file

@ -10,6 +10,6 @@ void foo(const A<N> &a)
void bar()
{
foo(A<0>()); // { dg-message "instantiated from here" "" }
foo(A<0>()); // { dg-message "required from here" "" }
}

View file

@ -10,4 +10,4 @@ template <typename T> struct S2 : S<T> {
using S<T>::operator typename S<T>::I*; // { dg-error "operator S\\<int\\>" "" }
};
template struct S2<int>; // { dg-message "instantiated" "" }
template struct S2<int>; // { dg-message "required" "" }

View file

@ -22,4 +22,4 @@ template <> struct X<int> {
X();
};
X<float> i; // { dg-message "instantiated from" "" }
X<float> i; // { dg-message "required from" "" }

View file

@ -19,4 +19,4 @@ struct S
static const int j = offsetof (S, i); // { dg-warning "invalid access|offsetof" }
};
int k = S<int>::j; // { dg-message "instantiated from here" }
int k = S<int>::j; // { dg-message "required from here" }

View file

@ -22,7 +22,7 @@ struct D
T t : 3; // { dg-error "non-integral type" }
};
D<double> d; // { dg-message "instantiated" }
D<double> d; // { dg-message "required" }
template <typename T>
struct E

View file

@ -34,7 +34,7 @@ template <typename> struct X
void Baz ()
{
Foo<int> (); // { dg-message "instantiated" "" }
Foo<int> (); // { dg-message "required" "" }
}

View file

@ -11,4 +11,4 @@ template<typename T> struct A
typedef typename T::X Y; // { dg-error "not a class" "" }
};
A<int>::Y y; // { dg-message "instantiated from here" "" }
A<int>::Y y; // { dg-message "required from here" "" }

View file

@ -11,4 +11,4 @@ template <int I> struct A
};
};
A<0>::B<0> a; // { dg-message "instantiated" }
A<0>::B<0> a; // { dg-message "required" }

View file

@ -31,7 +31,7 @@ int main()
Bar<int> bar;
bar.baz ();
bar.foo (); // { dg-message "instantiated" "" }
bar.foo (); // { dg-message "required" "" }
return 0;
}

View file

@ -49,4 +49,4 @@ template<int I> void f2()
A::template B<I>::template b2<double>(0);
}
template void f2<0>(); // { dg-message "instantiated" }
template void f2<0>(); // { dg-message "required" }

View file

@ -34,5 +34,5 @@ namespace N2 {
// { dg-message "candidate" "candidate note" { target *-*-* } 33 }
}
template int foo<float>(); // { dg-message "instantiated from here" }
template int foo<float>(); // { dg-message "required from here" }
}

View file

@ -32,7 +32,7 @@ namespace N {
template <> void f<double>(double )
{
M::B::x = 0;
M::f<long>(0); // { dg-message "instantiated" }
M::f<long>(0); // { dg-message "required" }
}
void g(void)
@ -47,7 +47,7 @@ namespace N {
template <> void f<int>(int )
{
N::f<long>(0); // { dg-message "instantiated" }
N::f<long>(0); // { dg-message "required" }
M::A::x = 0;
M::B::x = 0; // { dg-error "within this context" }
}

View file

@ -15,7 +15,7 @@ namespace N1 {
typename Derived::Base* p3; // { dg-bogus "" "injected class name in derived classes" }
};
template struct Derived<void>; // { dg-bogus "instantiated from here" "everything should be looked up at parsing time (after DR224)" }
template struct Derived<void>; // { dg-bogus "required from here" "everything should be looked up at parsing time (after DR224)" }
}

View file

@ -23,5 +23,5 @@ int main()
{
A<B> ab;
B b;
ab.h(b); // { dg-message "instantiated" }
ab.h(b); // { dg-message "required" }
}

View file

@ -21,4 +21,4 @@ template <typename T> struct X::Y {
typename T::X x; // { dg-error "this context" }
};
template struct X::Y<A>; // { dg-message "instantiated from here" }
template struct X::Y<A>; // { dg-message "required from here" }

View file

@ -15,6 +15,6 @@ class B {
int main()
{
A<B> ab; // { dg-message "instantiated" }
ab.f(); // { dg-message "instantiated" }
A<B> ab; // { dg-message "required" }
ab.f(); // { dg-message "required" }
}

View file

@ -13,5 +13,5 @@ class B {
int main()
{
A<B> ab; // { dg-message "instantiated" }
A<B> ab; // { dg-message "required" }
}

View file

@ -14,5 +14,5 @@ typename A::T* f (A) { // { dg-error "this context" }
}
void g () {
f (S<int> ()); // { dg-message "instantiated" }
f (S<int> ()); // { dg-message "required" }
}

View file

@ -8,4 +8,4 @@ template<typename T> struct A
B<C> b;
};
A<void> a; // { dg-message "instantiated" }
A<void> a; // { dg-message "required" }

View file

@ -6,5 +6,5 @@ template<int X> class c;
template<int X, int Y> int test(c<X ? : Y>&); // { dg-error "omitted" }
void test(c<2>*c2) {
test<0, 2>(*c2); // { dg-message "instantiated" }
test<0, 2>(*c2); // { dg-message "required" }
}

View file

@ -15,4 +15,4 @@ template <typename T> struct C
X::Y; // { dg-error "not a base type" }
};
C<void> c; // { dg-message "instantiated" }
C<void> c; // { dg-message "required" }

View file

@ -7,4 +7,4 @@ template<typename T> void foo()
T::~T(); // { dg-error "member" }
}
template void foo<A>(); // { dg-message "instantiated" }
template void foo<A>(); // { dg-message "required" }

View file

@ -10,5 +10,5 @@ template <typename> struct A // { dg-message "A.void.::A.const A" }
template <typename> A(typename A::X) {} // { dg-error "no type" }
};
A<void> a; // { dg-error "instantiated|no match" }
A<void> a; // { dg-error "required|no match" }
// { dg-prune-output "note" }

View file

@ -13,7 +13,7 @@ template<typename T> struct a
void
foo ()
{
a<int> v; // { dg-message "instantiated from here" }
a<int> v; // { dg-message "required from here" }
}

View file

@ -5,4 +5,4 @@ template<typename T> struct A
A() : T(0) {} // { dg-error "base" }
};
A<int*> a; // { dg-message "instantiated" }
A<int*> a; // { dg-message "required" }

View file

@ -16,4 +16,4 @@ struct C
typename T::F f; // { dg-error "no type" }
};
C<B, B> c; // { dg-message "instantiated" }
C<B, B> c; // { dg-message "required" }

View file

@ -1,5 +1,5 @@
// PR c++/46129
// The default argument for A<int>::B::operator() should not be instantiated
// The default argument for A<int>::B::operator() should not be required
template <class T>
struct A {

View file

@ -18,5 +18,5 @@ foo (T t)
void
bar ()
{
foo (B ()); // { dg-bogus "instantiated from here" "" { xfail *-*-* } }
foo (B ()); // { dg-bogus "required from here" "" { xfail *-*-* } }
}

View file

@ -7,4 +7,4 @@ template<typename T> struct A
void foo() throw(typename T::X); // { dg-error "not a class" }
};
A<void> a; // { dg-message "instantiated" }
A<void> a; // { dg-message "required" }

View file

@ -3,7 +3,7 @@
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 14 Aug 2003 <nathan@codesourcery.com>
// instantiated from did not indicate the nested class
// required from did not indicate the nested class
template<class T> struct X
{
@ -15,16 +15,16 @@ template<class T> struct X
template<class T >
struct Derived
{
class Nested : public X<T> // { dg-message "instantiated" "" }
class Nested : public X<T> // { dg-message "required" "" }
{
};
Nested m; // { dg-message "instantiated" "" }
Nested m; // { dg-message "required" "" }
void Foo ();
};
void Foo (Derived<void> &x)
{
x.Foo (); // { dg-message "instantiated" "" }
x.Foo (); // { dg-message "required" "" }
}

View file

@ -6,4 +6,4 @@ template<int> void foo()
struct A {} a;
}
template void foo<0>(); // { dg-message "instantiated" }
template void foo<0>(); // { dg-message "required" }

View file

@ -17,5 +17,5 @@ template<class T> class B
int f ()
{
B<int> b; // { dg-message "instantiated" }
B<int> b; // { dg-message "required" }
}

View file

@ -30,4 +30,4 @@ struct D4: Base<T>, Base<T*> {
typename D4::Base* p1; // { dg-error "" }
typename D4::template Base<double>* p2;
};
template struct D4<void>; // { dg-message "instantiated" }
template struct D4<void>; // { dg-message "required" }

View file

@ -9,11 +9,11 @@ template <class T> struct X {
};
template <class T> struct Y {
X<T> x; // { dg-message "instantiated" }
X<T> x; // { dg-message "required" }
};
template <class T> struct Z { // { dg-error "declaration" }
Y<Z<T> > y; // { dg-message "instantiated" }
Y<Z<T> > y; // { dg-message "required" }
};
struct ZZ : Z<int>

View file

@ -14,4 +14,4 @@ struct ACE_Cleanup_Adapter
TYPE object_; // { dg-error "incomplete type" }
};
template class ACE_Cleanup_Adapter<ACE_Null_Mutex>; // { dg-message "instantiated from here" }
template class ACE_Cleanup_Adapter<ACE_Null_Mutex>; // { dg-message "required from here" }

View file

@ -22,4 +22,4 @@ template <typename T> struct C
// { dg-message "candidate" "candidate note" { target *-*-* } 21 }
};
C<B> c; // { dg-message "instantiated" }
C<B> c; // { dg-message "required" }

View file

@ -7,4 +7,4 @@ template<typename T> struct A
template<T&> struct B; // { dg-error "reference to void" }
};
A<void> a; // { dg-message "instantiated" }
A<void> a; // { dg-message "required" }

View file

@ -16,5 +16,5 @@ void findIntersection( PCVector2<double>& p0, PCVector2<double>& p1);
void findIntersection( PCVector2<double>& p0, PCVector2<double>& p1)
{
PCVector2<double> e = p1 - p0; // { dg-message "instantiated" }
PCVector2<double> e = p1 - p0; // { dg-message "required" }
}

View file

@ -14,5 +14,5 @@ template <typename T> void Bar ()
void Foo ()
{
Bar<B> (); // { dg-message "instantiated" "" }
Bar<B> (); // { dg-message "required" "" }
}

View file

@ -28,6 +28,6 @@ struct S {
template< typename _A > void S::foo() {}
template void S::foo< 0 >(); // { dg-error "no definition available" "no def" }
// { dg-message "instantiated" "instantiated" { target *-*-* } 30 }
// { dg-message "required" "instantiated" { target *-*-* } 30 }
}

View file

@ -30,5 +30,5 @@ template<class T> void A<T>::B2::f()
int main()
{
A<int>::B2 b1;
b1.f(); // { dg-message "instantiated" }
b1.f(); // { dg-message "required" }
}

View file

@ -30,5 +30,5 @@ template<class T> template <class U> void A<T>::B2<U>::f()
int main()
{
A<int>::B2<int> b1;
b1.f(); // { dg-message "instantiated" }
b1.f(); // { dg-message "required" }
}

View file

@ -43,4 +43,4 @@ void A<T>::B::func2(void)
(void)F2<T*>::foo;
}
template class A<int>; // { dg-message "instantiated" }
template class A<int>; // { dg-message "required" }

View file

@ -116,18 +116,18 @@ template <> void A<char>::j<0>()
int main()
{
A<int *> a1;
a1.f(0); // { dg-message "instantiated" }
a1.g<char>(); // { dg-message "instantiated" }
a1.g<int>(); // { dg-message "instantiated" }
a1.h(); // { dg-message "instantiated" }
a1.i('a'); // { dg-message "instantiated" }
a1.j<1>(); // { dg-message "instantiated" }
a1.f(0); // { dg-message "required" }
a1.g<char>(); // { dg-message "required" }
a1.g<int>(); // { dg-message "required" }
a1.h(); // { dg-message "required" }
a1.i('a'); // { dg-message "required" }
a1.j<1>(); // { dg-message "required" }
A<char> a2;
a2.f(0);
a2.g<char>(); // { dg-message "instantiated" }
a2.g<char>(); // { dg-message "required" }
a2.g<int>();
a2.h();
a2.i('a');
a2.j<1>(); // { dg-message "instantiated" }
a2.j<1>(); // { dg-message "required" }
a2.j<0>();
}

View file

@ -5,4 +5,4 @@ struct S
S() : S() {} // { dg-error "base" }
};
S<int> s; // { dg-message "instantiated" }
S<int> s; // { dg-message "required" }

View file

@ -24,7 +24,7 @@ class B {
int main() {
B<char> objB; // { dg-message "instantiated" }
B<char> objB; // { dg-message "required" }
return 0;
}

View file

@ -9,4 +9,4 @@ template <typename T> struct D
C<T::X> c; // { dg-error "parsed as a non-type|if a type is meant" }
};
D<B> d; // { dg-message "instantiated from here" }
D<B> d; // { dg-message "required from here" }

View file

@ -9,7 +9,7 @@ template<typename T> struct A
};
A<char> a1;
A<double> a2; // { dg-message "instantiated" }
A<double> a2; // { dg-message "required" }
template<typename T> struct B
{
@ -27,9 +27,9 @@ template<typename T> struct C
template<T> int foo(); // { dg-error "double" }
};
template<typename T> int baz(T) { C<T> c; } // { dg-message "instantiated" }
template<typename T> int baz(T) { C<T> c; } // { dg-message "required" }
void foobar()
{
baz(1.2); // { dg-message "instantiated" }
baz(1.2); // { dg-message "required" }
}

View file

@ -24,6 +24,6 @@ struct Dummy
int main()
{
Dummy<int> d;
d.tester<true> (); // { dg-message "instantiated" }
d.tester<true> (); // { dg-message "required" }
}

View file

@ -16,4 +16,4 @@ void func(void)
// { dg-message "if a type" "note" { target *-*-* } 15 }
}
template void func<float>(void); // { dg-message "instantiated from here" }
template void func<float>(void); // { dg-message "required from here" }

View file

@ -4,7 +4,7 @@ template<unsigned int nFactor>
struct Factorial
{
enum { nValue = nFactor * Factorial<nFactor - 1>::nValue }; // { dg-error "depth exceeds maximum" }
// { dg-message "recursively instantiated" "" { target *-*-* } 6 }
// { dg-message "recursively required" "" { target *-*-* } 6 }
// { dg-error "incomplete type" "" { target *-*-* } 6 }
} // { dg-error "expected ';' after" }

View file

@ -8,5 +8,5 @@ template<int N> A<sizeof(new int[N][N])> foo(); // { dg-message "unimplemented"
void bar()
{
foo<1>(); // { dg-message "instantiated" }
foo<1>(); // { dg-message "required" }
}

View file

@ -6,4 +6,4 @@ template<typename T> struct A
T A::* p; // { dg-error "void" }
};
A<void> a; // { dg-message "instantiated" }
A<void> a; // { dg-message "required" }

View file

@ -7,4 +7,4 @@ void f (int T::* volatile *p) {
g(p); // { dg-error "conversion" }
}
template void f(int S::* volatile *); // { dg-message "instantiated" }
template void f(int S::* volatile *); // { dg-message "required" }

View file

@ -23,5 +23,5 @@ template <typename T> void foo()
void bar()
{
foo<A>(); // { dg-message "instantiated" }
foo<A>(); // { dg-message "required" }
}

View file

@ -32,5 +32,5 @@ template <typename T> struct B2 : T
myconst b;
};
B1<AS> b1; // { dg-message "instantiated" "" }
B1<AS> b1; // { dg-message "required" "" }
B2<AS> b2;

View file

@ -19,5 +19,5 @@ template <class T> struct C
int main()
{
C<A> c; // { dg-message "instantiated" }
C<A> c; // { dg-message "required" }
}

View file

@ -20,5 +20,5 @@ template <class T> struct C
int main()
{
C<A> c; // { dg-message "instantiated" }
C<A> c; // { dg-message "required" }
}

View file

@ -16,11 +16,11 @@ template <template <class> class TT> void f()
template <class T> struct C
{
void g() { f<A<T>::template B>(); } // { dg-message "instantiated" }
void g() { f<A<T>::template B>(); } // { dg-message "required" }
};
int main()
{
C<int> c;
c.g(); // { dg-message "instantiated" }
c.g(); // { dg-message "required" }
}

View file

@ -12,4 +12,4 @@ template <class T> struct D {
struct E {
};
D<E> d; // { dg-message "instantiated" }
D<E> d; // { dg-message "required" }

View file

@ -9,4 +9,4 @@ template <class T> struct D {
C<T::template B> c; // { dg-error "no class template" }
};
D<int> d; // { dg-message "instantiated" }
D<int> d; // { dg-message "required" }

View file

@ -14,4 +14,4 @@ struct E {
template <class T> class B {}; // { dg-error "private" }
};
D<E> d; // { dg-message "instantiated" }
D<E> d; // { dg-message "required" }

View file

@ -8,7 +8,7 @@ template <int I> struct F
F<I+1> f; // { dg-error "incomplete type" "incomplete" }
// { dg-bogus "exceeds maximum.*exceeds maximum" "exceeds" { xfail *-*-* } 8 }
// { dg-error "exceeds maximum" "exceeds" { xfail *-*-* } 8 }
return f()*I; // { dg-message "recursively instantiated" "recurse" }
return f()*I; // { dg-message "recursively" "recurse" }
}
};
@ -20,8 +20,8 @@ template <> struct F<52>
int main ()
{
F<1> f;
return f(); // { dg-message "instantiated from here" "excessive recursion" }
return f(); // { dg-message "from here" "excessive recursion" }
}
// Ignore excess messages from recursion.
// { dg-prune-output "instantiated from 'int" }
// { dg-prune-output "from 'int" }

View file

@ -3,6 +3,6 @@
template <int N> struct X {
static const int value = X<N-1>::value; // { dg-error "instantiation|incomplete" }
// { dg-message "recursively instantiated" "" { target *-*-* } 5 }
// { dg-message "recursively required" "" { target *-*-* } 5 }
};
template struct X<1000>;

View file

@ -8,4 +8,4 @@ template<typename T> struct B
A<t> a; // { dg-error "reference variable" }
};
B<int&> b; // { dg-message "instantiated" }
B<int&> b; // { dg-message "required" }

View file

@ -3,7 +3,7 @@
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 15 Aug 2003 <nathan@codesourcery.com>
// checked instantiated bases in wrong scope.
// checked required bases in wrong scope.
class Helper {};

View file

@ -169,13 +169,13 @@ STATIC_ASSERT((has_postdecrement<X>::value));
STATIC_ASSERT((!has_postdecrement<Y>::value));
// Check for private members
STATIC_ASSERT((has_unary_plus<Z>::value)); // { dg-message "instantiated from here" }
STATIC_ASSERT((is_negatable<Z>::value)); // { dg-message "instantiated from here" }
STATIC_ASSERT((is_dereferenceable<Z>::value)); // { dg-message "instantiated from here" }
STATIC_ASSERT((has_bitwise_not<Z>::value)); // { dg-message "instantiated from here" }
STATIC_ASSERT((has_truth_not<Z>::value)); // { dg-message "instantiated from here" }
STATIC_ASSERT((has_preincrement<Z>::value)); // { dg-message "instantiated from here" }
STATIC_ASSERT((has_predecrement<Z>::value)); // { dg-message "instantiated from here" }
STATIC_ASSERT((has_postincrement<Z>::value)); // { dg-message "instantiated from here" }
STATIC_ASSERT((has_postdecrement<Z>::value)); // { dg-message "instantiated from here" }
STATIC_ASSERT((has_unary_plus<Z>::value)); // { dg-message "required from here" }
STATIC_ASSERT((is_negatable<Z>::value)); // { dg-message "required from here" }
STATIC_ASSERT((is_dereferenceable<Z>::value)); // { dg-message "required from here" }
STATIC_ASSERT((has_bitwise_not<Z>::value)); // { dg-message "required from here" }
STATIC_ASSERT((has_truth_not<Z>::value)); // { dg-message "required from here" }
STATIC_ASSERT((has_preincrement<Z>::value)); // { dg-message "required from here" }
STATIC_ASSERT((has_predecrement<Z>::value)); // { dg-message "required from here" }
STATIC_ASSERT((has_postincrement<Z>::value)); // { dg-message "required from here" }
STATIC_ASSERT((has_postdecrement<Z>::value)); // { dg-message "required from here" }

View file

@ -14,4 +14,4 @@ template<typename> struct B
template<typename T> B(T, Y);
};
B<int> b(0,0); // { dg-message "instantiated from here" }
B<int> b(0,0); // { dg-message "required from here" }

Some files were not shown because too many files have changed in this diff Show more