This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ diagnostics: Use quoting flag q (6/n)
- From: Gabriel Dos Reis <gdr at cs dot tamu dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: 05 Oct 2004 15:14:01 -0500
- Subject: C++ diagnostics: Use quoting flag q (6/n)
- Organization: Texas A&M University, Department of Computer Science
Bootstrapped and regtested on an i686-pc-linux-gnu.
2004-10-05 Gabriel Dos Reis <gdr@cs.tamu.edu>
Convert diagnostics to use quoting flag q 6/n
* pt.c (finish_member_template_decl, check_specialization_scope,
maybe_process_partial_specialization, determine_specialization,
check_explicit_specialization, maybe_check_template_type,
process_partial_specialization, check_default_tmpl_args,
push_template_decl_real, redeclare_class_template,
convert_nontype_argument, coerce_template_parms,
lookup_template_class, push_tinst_level,
instantiate_class_template, tsubst_arg_types,
tsubst_function_type, tsubst, tsubst_qualified_id,
tsubst_copy_and_build, check_instantiated_args,
do_decl_instantiation, do_type_instantiation,
invalid_nontype_parm_type_p, check_specialization_namespace,
convert_template_argument, determine_specialization,
check_template_shadow, tsubst_decl
instantiate_pending_templates): Use quoting marks.
Index: pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.929
diff -p -r1.929 pt.c
*** pt.c 28 Sep 2004 08:50:56 -0000 1.929
--- pt.c 5 Oct 2004 20:08:37 -0000
*************** finish_member_template_decl (tree decl)
*** 237,243 ****
return NULL_TREE;
}
else if (TREE_CODE (decl) == FIELD_DECL)
! error ("data member `%D' cannot be a member template", decl);
else if (DECL_TEMPLATE_INFO (decl))
{
if (!DECL_TEMPLATE_SPECIALIZATION (decl))
--- 237,243 ----
return NULL_TREE;
}
else if (TREE_CODE (decl) == FIELD_DECL)
! error ("data member %qD cannot be a member template", decl);
else if (DECL_TEMPLATE_INFO (decl))
{
if (!DECL_TEMPLATE_SPECIALIZATION (decl))
*************** finish_member_template_decl (tree decl)
*** 249,255 ****
return decl;
}
else
! error ("invalid member template declaration `%D'", decl);
return error_mark_node;
}
--- 249,255 ----
return decl;
}
else
! error ("invalid member template declaration %qD", decl);
return error_mark_node;
}
*************** check_specialization_scope (void)
*** 632,639 ****
shall be declared in the namespace of which the class template
is a member. */
if (scope && TREE_CODE (scope) != NAMESPACE_DECL)
! error ("explicit specialization in non-namespace scope `%D'",
! scope);
/* [temp.expl.spec]
--- 632,638 ----
shall be declared in the namespace of which the class template
is a member. */
if (scope && TREE_CODE (scope) != NAMESPACE_DECL)
! error ("explicit specialization in non-namespace scope %qD", scope);
/* [temp.expl.spec]
*************** check_specialization_namespace (tree tmp
*** 728,735 ****
return true;
else
{
! pedwarn ("specialization of `%D' in different namespace", tmpl);
! cp_pedwarn_at (" from definition of `%#D'", tmpl);
return false;
}
}
--- 727,734 ----
return true;
else
{
! pedwarn ("specialization of %qD in different namespace", tmpl);
! cp_pedwarn_at (" from definition of %q#D", tmpl);
return false;
}
}
*************** maybe_process_partial_specialization (tr
*** 765,771 ****
push_template_decl (TYPE_MAIN_DECL (type));
}
else if (CLASSTYPE_TEMPLATE_INSTANTIATION (type))
! error ("specialization of `%T' after instantiation", type);
}
else if (CLASS_TYPE_P (type)
&& !CLASSTYPE_USE_TEMPLATE (type)
--- 764,770 ----
push_template_decl (TYPE_MAIN_DECL (type));
}
else if (CLASSTYPE_TEMPLATE_INSTANTIATION (type))
! error ("specialization of %qT after instantiation", type);
}
else if (CLASS_TYPE_P (type)
&& !CLASSTYPE_USE_TEMPLATE (type)
*************** maybe_process_partial_specialization (tr
*** 797,804 ****
if (current_namespace
!= decl_namespace_context (CLASSTYPE_TI_TEMPLATE (type)))
{
! pedwarn ("specializing `%#T' in different namespace", type);
! cp_pedwarn_at (" from definition of `%#D'",
CLASSTYPE_TI_TEMPLATE (type));
}
--- 796,803 ----
if (current_namespace
!= decl_namespace_context (CLASSTYPE_TI_TEMPLATE (type)))
{
! pedwarn ("specializing %q#T in different namespace", type);
! cp_pedwarn_at (" from definition of %q#D",
CLASSTYPE_TI_TEMPLATE (type));
}
*************** maybe_process_partial_specialization (tr
*** 812,818 ****
t; t = TREE_CHAIN (t))
if (TREE_VALUE (t) != type
&& TYPE_CONTEXT (TREE_VALUE (t)) == context)
! error ("specialization `%T' after instantiation `%T'",
type, TREE_VALUE (t));
/* Mark TYPE as a specialization. And as a result, we only
--- 811,817 ----
t; t = TREE_CHAIN (t))
if (TREE_VALUE (t) != type
&& TYPE_CONTEXT (TREE_VALUE (t)) == context)
! error ("specialization %qT after instantiation %qT",
type, TREE_VALUE (t));
/* Mark TYPE as a specialization. And as a result, we only
*************** maybe_process_partial_specialization (tr
*** 824,830 ****
}
}
else if (processing_specialization)
! error ("explicit specialization of non-template `%T'", type);
}
/* Retrieve the specialization (in the sense of [temp.spec] - a
--- 823,829 ----
}
}
else if (processing_specialization)
! error ("explicit specialization of non-template %qT", type);
}
/* Retrieve the specialization (in the sense of [temp.spec] - a
*************** register_specialization (tree spec, tree
*** 1081,1088 ****
if (TREE_USED (fn)
|| DECL_EXPLICIT_INSTANTIATION (fn))
{
! error ("specialization of %D after instantiation",
! fn);
return spec;
}
else
--- 1080,1086 ----
if (TREE_USED (fn)
|| DECL_EXPLICIT_INSTANTIATION (fn))
{
! error ("specialization of %qD after instantiation", fn);
return spec;
}
else
*************** determine_specialization (tree template_
*** 1267,1273 ****
if (!is_overloaded_fn (fns))
{
! error ("`%D' is not a function template", fns);
return error_mark_node;
}
--- 1265,1271 ----
if (!is_overloaded_fn (fns))
{
! error ("%qD is not a function template", fns);
return error_mark_node;
}
*************** determine_specialization (tree template_
*** 1452,1458 ****
if (templates == NULL_TREE && candidates == NULL_TREE)
{
! cp_error_at ("template-id `%D' for `%+D' does not match any template declaration",
template_id, decl);
return error_mark_node;
}
--- 1450,1457 ----
if (templates == NULL_TREE && candidates == NULL_TREE)
{
! cp_error_at ("template-id %qD for %q+D does not match any template "
! "declaration",
template_id, decl);
return error_mark_node;
}
*************** determine_specialization (tree template_
*** 1460,1466 ****
|| (candidates && TREE_CHAIN (candidates))
|| (templates && candidates))
{
! cp_error_at ("ambiguous template specialization `%D' for `%+D'",
template_id, decl);
chainon (candidates, templates);
print_candidates (candidates);
--- 1459,1465 ----
|| (candidates && TREE_CHAIN (candidates))
|| (templates && candidates))
{
! cp_error_at ("ambiguous template specialization %qD for %q+D",
template_id, decl);
chainon (candidates, templates);
print_candidates (candidates);
*************** check_explicit_specialization (tree decl
*** 1683,1690 ****
/* This case handles bogus declarations like template <>
template <class T> void f<int>(); */
! error ("template-id `%D' in declaration of primary template",
! declarator);
return decl;
}
}
--- 1682,1689 ----
/* This case handles bogus declarations like template <>
template <class T> void f<int>(); */
! error ("template-id %qD in declaration of primary template",
! declarator);
return decl;
}
}
*************** check_explicit_specialization (tree decl
*** 1710,1722 ****
case tsk_excessive_parms:
case tsk_insufficient_parms:
if (tsk == tsk_excessive_parms)
! error ("too many template parameter lists in declaration of `%D'",
decl);
else if (template_header_count)
! error("too few template parameter lists in declaration of `%D'",
! decl);
else
! error("explicit specialization of `%D' must be introduced by "
"`template <>'", decl);
/* Fall through. */
--- 1709,1720 ----
case tsk_excessive_parms:
case tsk_insufficient_parms:
if (tsk == tsk_excessive_parms)
! error ("too many template parameter lists in declaration of %qD",
decl);
else if (template_header_count)
! error("too few template parameter lists in declaration of %qD", decl);
else
! error("explicit specialization of %qD must be introduced by "
"`template <>'", decl);
/* Fall through. */
*************** check_explicit_specialization (tree decl
*** 1735,1745 ****
template <class T> void f<int>(); */
if (uses_template_parms (declarator))
! error ("function template partial specialization `%D' "
"is not allowed", declarator);
else
! error ("template-id `%D' in declaration of primary template",
! declarator);
return decl;
}
--- 1733,1743 ----
template <class T> void f<int>(); */
if (uses_template_parms (declarator))
! error ("function template partial specialization %qD "
"is not allowed", declarator);
else
! error ("template-id %qD in declaration of primary template",
! declarator);
return decl;
}
*************** check_explicit_specialization (tree decl
*** 1899,1906 ****
if (fns == NULL_TREE)
{
! error ("no member function `%D' declared in `%T'",
! name, ctype);
return error_mark_node;
}
else
--- 1897,1903 ----
if (fns == NULL_TREE)
{
! error ("no member function %qD declared in %qT", name, ctype);
return error_mark_node;
}
else
*************** maybe_check_template_type (tree type)
*** 2050,2056 ****
;
else if (template_header_count > context_depth + 1)
/* There are two many template parameter lists. */
! error ("too many template parameter lists in declaration of `%T'", type);
}
}
--- 2047,2053 ----
;
else if (template_header_count > context_depth + 1)
/* There are two many template parameter lists. */
! error ("too many template parameter lists in declaration of %qT", type);
}
}
*************** check_template_shadow (tree decl)
*** 2143,2150 ****
|| TEMPLATE_PARMS_FOR_INLINE (current_template_parms))
return;
! cp_error_at ("declaration of `%#D'", decl);
! cp_error_at (" shadows template parm `%#D'", olddecl);
}
/* Return a new TEMPLATE_PARM_INDEX with the indicated INDEX, LEVEL,
--- 2140,2147 ----
|| TEMPLATE_PARMS_FOR_INLINE (current_template_parms))
return;
! cp_error_at ("declaration of %q#D", decl);
! cp_error_at (" shadows template parm %q#D", olddecl);
}
/* Return a new TEMPLATE_PARM_INDEX with the indicated INDEX, LEVEL,
*************** process_partial_specialization (tree dec
*** 2548,2555 ****
did_error_intro = 1;
}
! error (" `%D'",
! TREE_VALUE (TREE_VEC_ELT (inner_parms, i)));
}
/* [temp.class.spec]
--- 2545,2551 ----
did_error_intro = 1;
}
! error (" %qD", TREE_VALUE (TREE_VEC_ELT (inner_parms, i)));
}
/* [temp.class.spec]
*************** process_partial_specialization (tree dec
*** 2560,2566 ****
(inner_args,
INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (TREE_TYPE
(maintmpl)))))
! error ("partial specialization `%T' does not specialize any template arguments", type);
/* [temp.class.spec]
--- 2556,2562 ----
(inner_args,
INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (TREE_TYPE
(maintmpl)))))
! error ("partial specialization %qT does not specialize any template arguments", type);
/* [temp.class.spec]
*************** process_partial_specialization (tree dec
*** 2585,2591 ****
&& TREE_CODE (arg) != TEMPLATE_PARM_INDEX)
{
if (tpd.arg_uses_template_parms[i])
! error ("template argument `%E' involves template parameter(s)", arg);
else
{
/* Look at the corresponding template parameter,
--- 2581,2587 ----
&& TREE_CODE (arg) != TEMPLATE_PARM_INDEX)
{
if (tpd.arg_uses_template_parms[i])
! error ("template argument %qE involves template parameter(s)", arg);
else
{
/* Look at the corresponding template parameter,
*************** process_partial_specialization (tree dec
*** 2629,2637 ****
if (tpd2.parms[j] != 0
&& tpd.arg_uses_template_parms [j])
{
! error ("type `%T' of template argument `%E' depends on template parameter(s)",
! type,
! arg);
break;
}
}
--- 2625,2634 ----
if (tpd2.parms[j] != 0
&& tpd.arg_uses_template_parms [j])
{
! error ("type %qT of template argument %qE depends "
! "on template parameter(s)",
! type,
! arg);
break;
}
}
*************** check_default_tmpl_args (tree decl, tree
*** 2714,2720 ****
seen_def_arg_p = 1;
else if (seen_def_arg_p)
{
! error ("no default argument for `%D'", TREE_VALUE (parm));
/* For better subsequent error-recovery, we indicate that
there should have been a default argument. */
TREE_PURPOSE (parm) = error_mark_node;
--- 2711,2717 ----
seen_def_arg_p = 1;
else if (seen_def_arg_p)
{
! error ("no default argument for %qD", TREE_VALUE (parm));
/* For better subsequent error-recovery, we indicate that
there should have been a default argument. */
TREE_PURPOSE (parm) = error_mark_node;
*************** check_default_tmpl_args (tree decl, tree
*** 2748,2754 ****
else if (is_partial)
msg = "default template arguments may not be used in partial specializations";
else
! msg = "default argument for template parameter for class enclosing `%D'";
if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
/* If we're inside a class definition, there's no need to
--- 2745,2751 ----
else if (is_partial)
msg = "default template arguments may not be used in partial specializations";
else
! msg = "default argument for template parameter for class enclosing %qD";
if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
/* If we're inside a class definition, there's no need to
*************** check_default_tmpl_args (tree decl, tree
*** 2790,2796 ****
/* At this point, if we're still interested in issuing messages,
they must apply to classes surrounding the object declared. */
if (msg)
! msg = "default argument for template parameter for class enclosing `%D'";
}
}
--- 2787,2793 ----
/* At this point, if we're still interested in issuing messages,
they must apply to classes surrounding the object declared. */
if (msg)
! msg = "default argument for template parameter for class enclosing %qD";
}
}
*************** push_template_decl_real (tree decl, int
*** 2877,2883 ****
/* [temp.mem]
A destructor shall not be a member template. */
! error ("destructor `%D' declared as member template", decl);
return error_mark_node;
}
if (NEW_DELETE_OPNAME_P (DECL_NAME (decl))
--- 2874,2880 ----
/* [temp.mem]
A destructor shall not be a member template. */
! error ("destructor %qD declared as member template", decl);
return error_mark_node;
}
if (NEW_DELETE_OPNAME_P (DECL_NAME (decl))
*************** push_template_decl_real (tree decl, int
*** 2892,2898 ****
An allocation function can be a function
template. ... Template allocation functions shall
have two or more parameters. */
! error ("invalid template declaration of `%D'", decl);
return decl;
}
}
--- 2889,2895 ----
An allocation function can be a function
template. ... Template allocation functions shall
have two or more parameters. */
! error ("invalid template declaration of %qD", decl);
return decl;
}
}
*************** push_template_decl_real (tree decl, int
*** 2902,2908 ****
/* OK */;
else
{
! error ("template declaration of `%#D'", decl);
return error_mark_node;
}
}
--- 2899,2905 ----
/* OK */;
else
{
! error ("template declaration of %q#D", decl);
return error_mark_node;
}
}
*************** push_template_decl_real (tree decl, int
*** 2972,2984 ****
tmpl = TYPE_TI_TEMPLATE (TREE_TYPE (decl));
else
{
! error ("`%D' does not declare a template type", decl);
return decl;
}
}
else if (!DECL_LANG_SPECIFIC (decl) || !DECL_TEMPLATE_INFO (decl))
{
! error ("template definition of non-template `%#D'", decl);
return decl;
}
else
--- 2969,2981 ----
tmpl = TYPE_TI_TEMPLATE (TREE_TYPE (decl));
else
{
! error ("%qD does not declare a template type", decl);
return decl;
}
}
else if (!DECL_LANG_SPECIFIC (decl) || !DECL_TEMPLATE_INFO (decl))
{
! error ("template definition of non-template %q#D", decl);
return decl;
}
else
*************** push_template_decl_real (tree decl, int
*** 3019,3026 ****
i = TMPL_PARMS_DEPTH (parms);
if (TMPL_ARGS_DEPTH (args) != i)
{
! error ("expected %d levels of template parms for `%#D', got %d",
! i, decl, TMPL_ARGS_DEPTH (args));
}
else
for (current = decl; i > 0; --i, parms = TREE_CHAIN (parms))
--- 3016,3023 ----
i = TMPL_PARMS_DEPTH (parms);
if (TMPL_ARGS_DEPTH (args) != i)
{
! error ("expected %d levels of template parms for %q#D, got %d",
! i, decl, TMPL_ARGS_DEPTH (args));
}
else
for (current = decl; i > 0; --i, parms = TREE_CHAIN (parms))
*************** push_template_decl_real (tree decl, int
*** 3031,3041 ****
if (TREE_VEC_LENGTH (t) != TREE_VEC_LENGTH (a))
{
if (current == decl)
! error ("got %d template parameters for `%#D'",
! TREE_VEC_LENGTH (a), decl);
else
! error ("got %d template parameters for `%#T'",
! TREE_VEC_LENGTH (a), current);
error (" but %d required", TREE_VEC_LENGTH (t));
}
--- 3028,3038 ----
if (TREE_VEC_LENGTH (t) != TREE_VEC_LENGTH (a))
{
if (current == decl)
! error ("got %d template parameters for %q#D",
! TREE_VEC_LENGTH (a), decl);
else
! error ("got %d template parameters for %q#T",
! TREE_VEC_LENGTH (a), current);
error (" but %d required", TREE_VEC_LENGTH (t));
}
*************** redeclare_class_template (tree type, tre
*** 3121,3127 ****
if (!TYPE_TEMPLATE_INFO (type))
{
! error ("`%T' is not a template type", type);
return;
}
--- 3118,3124 ----
if (!TYPE_TEMPLATE_INFO (type))
{
! error ("%qT is not a template type", type);
return;
}
*************** redeclare_class_template (tree type, tre
*** 3137,3143 ****
if (TREE_VEC_LENGTH (parms) != TREE_VEC_LENGTH (tmpl_parms))
{
! cp_error_at ("previous declaration `%D'", tmpl);
error ("used %d template parameter%s instead of %d",
TREE_VEC_LENGTH (tmpl_parms),
TREE_VEC_LENGTH (tmpl_parms) == 1 ? "" : "s",
--- 3134,3140 ----
if (TREE_VEC_LENGTH (parms) != TREE_VEC_LENGTH (tmpl_parms))
{
! cp_error_at ("previous declaration %qD", tmpl);
error ("used %d template parameter%s instead of %d",
TREE_VEC_LENGTH (tmpl_parms),
TREE_VEC_LENGTH (tmpl_parms) == 1 ? "" : "s",
*************** redeclare_class_template (tree type, tre
*** 3158,3165 ****
|| (TREE_CODE (tmpl_parm) != TYPE_DECL
&& !same_type_p (TREE_TYPE (tmpl_parm), TREE_TYPE (parm))))
{
! cp_error_at ("template parameter `%#D'", tmpl_parm);
! error ("redeclared here as `%#D'", parm);
return;
}
--- 3155,3162 ----
|| (TREE_CODE (tmpl_parm) != TYPE_DECL
&& !same_type_p (TREE_TYPE (tmpl_parm), TREE_TYPE (parm))))
{
! cp_error_at ("template parameter %q#D", tmpl_parm);
! error ("redeclared here as %q#D", parm);
return;
}
*************** redeclare_class_template (tree type, tre
*** 3169,3175 ****
A template-parameter may not be given default arguments
by two different declarations in the same scope. */
! error ("redefinition of default argument for `%#D'", parm);
error ("%J original definition appeared here", tmpl_parm);
return;
}
--- 3166,3172 ----
A template-parameter may not be given default arguments
by two different declarations in the same scope. */
! error ("redefinition of default argument for %q#D", parm);
error ("%J original definition appeared here", tmpl_parm);
return;
}
*************** convert_nontype_argument (tree type, tre
*** 3316,3322 ****
if (TREE_CODE (e) != ADDR_EXPR)
{
bad_argument:
! error ("`%E' is not a valid template argument", expr);
if (TYPE_PTR_P (expr_type))
{
if (TREE_CODE (TREE_TYPE (expr_type)) == FUNCTION_TYPE)
--- 3313,3319 ----
if (TREE_CODE (e) != ADDR_EXPR)
{
bad_argument:
! error ("%qE is not a valid template argument", expr);
if (TYPE_PTR_P (expr_type))
{
if (TREE_CODE (TREE_TYPE (expr_type)) == FUNCTION_TYPE)
*************** convert_nontype_argument (tree type, tre
*** 3325,3331 ****
error ("it must be the address of an object with external linkage");
}
else if (TYPE_PTR_TO_MEMBER_P (expr_type))
! error ("it must be a pointer-to-member of the form `&X::Y'");
return NULL_TREE;
}
--- 3322,3328 ----
error ("it must be the address of an object with external linkage");
}
else if (TYPE_PTR_TO_MEMBER_P (expr_type))
! error ("it must be a pointer-to-member of the form %<&X::Y%>");
return NULL_TREE;
}
*************** convert_nontype_argument (tree type, tre
*** 3336,3343 ****
if (TREE_CODE (referent) == STRING_CST)
{
! error ("string literal %E is not a valid template argument because it is the address of an object with static linkage",
! referent);
return NULL_TREE;
}
--- 3333,3341 ----
if (TREE_CODE (referent) == STRING_CST)
{
! error ("string literal %qE is not a valid template argument "
! "because it is the address of an object with static linkage",
! referent);
return NULL_TREE;
}
*************** convert_nontype_argument (tree type, tre
*** 3351,3357 ****
goto bad_argument;
else if (!DECL_EXTERNAL_LINKAGE_P (referent))
{
! error ("address of non-extern `%E' cannot be used as template argument", referent);
return error_mark_node;
}
}
--- 3349,3356 ----
goto bad_argument;
else if (!DECL_EXTERNAL_LINKAGE_P (referent))
{
! error ("address of non-extern %qE cannot be used as "
! "template argument", referent);
return error_mark_node;
}
}
*************** convert_nontype_argument (tree type, tre
*** 3360,3379 ****
if (! TREE_CONSTANT (expr))
{
non_constant:
! error ("non-constant `%E' cannot be used as template argument",
! expr);
return NULL_TREE;
}
}
else
{
if (TYPE_P (expr))
! error ("type '%T' cannot be used as a value for a non-type "
"template-parameter", expr);
else if (DECL_P (expr))
! error ("invalid use of '%D' as a non-type template-argument", expr);
else
! error ("invalid use of '%E' as a non-type template-argument", expr);
return NULL_TREE;
}
--- 3359,3377 ----
if (! TREE_CONSTANT (expr))
{
non_constant:
! error ("non-constant %qE cannot be used as template argument", expr);
return NULL_TREE;
}
}
else
{
if (TYPE_P (expr))
! error ("type %qT cannot be used as a value for a non-type "
"template-parameter", expr);
else if (DECL_P (expr))
! error ("invalid use of %qD as a non-type template-argument", expr);
else
! error ("invalid use of %qE as a non-type template-argument", expr);
return NULL_TREE;
}
*************** convert_template_argument (tree parm,
*** 3751,3757 ****
if (requires_type && ! is_type && TREE_CODE (arg) == SCOPE_REF
&& TREE_CODE (TREE_OPERAND (arg, 0)) == TEMPLATE_TYPE_PARM)
{
! pedwarn ("to refer to a type member of a template parameter, use `typename %E'", arg);
arg = make_typename_type (TREE_OPERAND (arg, 0),
TREE_OPERAND (arg, 1),
--- 3749,3756 ----
if (requires_type && ! is_type && TREE_CODE (arg) == SCOPE_REF
&& TREE_CODE (TREE_OPERAND (arg, 0)) == TEMPLATE_TYPE_PARM)
{
! pedwarn ("to refer to a type member of a template parameter, "
! "use %<typename %E%>", arg);
arg = make_typename_type (TREE_OPERAND (arg, 0),
TREE_OPERAND (arg, 1),
*************** convert_template_argument (tree parm,
*** 3764,3779 ****
{
if (complain & tf_error)
{
! error ("type/value mismatch at argument %d in template parameter list for `%D'",
! i + 1, in_decl);
if (is_type)
! error (" expected a constant of type `%T', got `%T'",
! TREE_TYPE (parm),
! (is_tmpl_type ? DECL_NAME (arg) : arg));
else if (requires_tmpl_type)
! error (" expected a class template, got `%E'", arg);
else
! error (" expected a type, got `%E'", arg);
}
}
return error_mark_node;
--- 3763,3779 ----
{
if (complain & tf_error)
{
! error ("type/value mismatch at argument %d in template "
! "parameter list for %qD",
! i + 1, in_decl);
if (is_type)
! error (" expected a constant of type %qT, got %qT",
! TREE_TYPE (parm),
! (is_tmpl_type ? DECL_NAME (arg) : arg));
else if (requires_tmpl_type)
! error (" expected a class template, got %qE", arg);
else
! error (" expected a type, got %qE", arg);
}
}
return error_mark_node;
*************** convert_template_argument (tree parm,
*** 3782,3793 ****
{
if (in_decl && (complain & tf_error))
{
! error ("type/value mismatch at argument %d in template parameter list for `%D'",
! i + 1, in_decl);
if (is_tmpl_type)
! error (" expected a type, got `%T'", DECL_NAME (arg));
else
! error (" expected a class template, got `%T'", arg);
}
return error_mark_node;
}
--- 3782,3794 ----
{
if (in_decl && (complain & tf_error))
{
! error ("type/value mismatch at argument %d in template "
! "parameter list for %qD",
! i + 1, in_decl);
if (is_tmpl_type)
! error (" expected a type, got %qT", DECL_NAME (arg));
else
! error (" expected a class template, got %qT", arg);
}
return error_mark_node;
}
*************** convert_template_argument (tree parm,
*** 3821,3829 ****
{
if (in_decl && (complain & tf_error))
{
! error ("type/value mismatch at argument %d in template parameter list for `%D'",
! i + 1, in_decl);
! error (" expected a template of type `%D', got `%D'", parm, arg);
}
val = error_mark_node;
--- 3822,3832 ----
{
if (in_decl && (complain & tf_error))
{
! error ("type/value mismatch at argument %d in "
! "template parameter list for %qD",
! i + 1, in_decl);
! error (" expected a template of type %qD, got %qD",
! parm, arg);
}
val = error_mark_node;
*************** convert_template_argument (tree parm,
*** 3858,3865 ****
if (val == NULL_TREE)
val = error_mark_node;
else if (val == error_mark_node && (complain & tf_error))
! error ("could not convert template argument `%E' to `%T'",
! arg, t);
}
return val;
--- 3861,3867 ----
if (val == NULL_TREE)
val = error_mark_node;
else if (val == error_mark_node && (complain & tf_error))
! error ("could not convert template argument %qE to %qT", arg, t);
}
return val;
*************** coerce_template_parms (tree parms,
*** 3899,3908 ****
if (complain & tf_error)
{
error ("wrong number of template arguments (%d, should be %d)",
! nargs, nparms);
if (in_decl)
! cp_error_at ("provided for `%D'", in_decl);
}
return error_mark_node;
--- 3901,3910 ----
if (complain & tf_error)
{
error ("wrong number of template arguments (%d, should be %d)",
! nargs, nparms);
if (in_decl)
! cp_error_at ("provided for %qD", in_decl);
}
return error_mark_node;
*************** lookup_template_class (tree d1,
*** 4274,4280 ****
if (! template)
{
if (complain & tf_error)
! error ("`%T' is not a template", d1);
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
}
--- 4276,4282 ----
if (! template)
{
if (complain & tf_error)
! error ("%qT is not a template", d1);
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
}
*************** lookup_template_class (tree d1,
*** 4286,4294 ****
{
if (complain & tf_error)
{
! error ("non-template type `%T' used as a template", d1);
if (in_decl)
! cp_error_at ("for template declaration `%D'", in_decl);
}
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
}
--- 4288,4296 ----
{
if (complain & tf_error)
{
! error ("non-template type %qT used as a template", d1);
if (in_decl)
! cp_error_at ("for template declaration %qD", in_decl);
}
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
}
*************** push_tinst_level (tree d)
*** 4937,4943 ****
return 0;
last_template_error_tick = tinst_level_tick;
! error ("template instantiation depth exceeds maximum of %d (use -ftemplate-depth-NN to increase the maximum) instantiating `%D'",
max_tinst_depth, d);
print_instantiation_context ();
--- 4939,4946 ----
return 0;
last_template_error_tick = tinst_level_tick;
! error ("template instantiation depth exceeds maximum of %d (use "
! "-ftemplate-depth-NN to increase the maximum) instantiating %qD",
max_tinst_depth, d);
print_instantiation_context ();
*************** instantiate_class_template (tree type)
*** 5375,5381 ****
if (t == error_mark_node)
{
const char *str = "candidates are:";
! error ("ambiguous class template instantiation for `%#T'", type);
for (t = DECL_TEMPLATE_SPECIALIZATIONS (template); t;
t = TREE_CHAIN (t))
{
--- 5378,5384 ----
if (t == error_mark_node)
{
const char *str = "candidates are:";
! error ("ambiguous class template instantiation for %q#T", type);
for (t = DECL_TEMPLATE_SPECIALIZATIONS (template); t;
t = TREE_CHAIN (t))
{
*************** tsubst_decl (tree t, tree args, tree typ
*** 6402,6408 ****
complain, in_decl);
TREE_CHAIN (r) = NULL_TREE;
if (VOID_TYPE_P (type))
! cp_error_at ("instantiation of `%D' as type `%T'", r, type);
}
break;
--- 6405,6411 ----
complain, in_decl);
TREE_CHAIN (r) = NULL_TREE;
if (VOID_TYPE_P (type))
! cp_error_at ("instantiation of %qD as type %qT", r, type);
}
break;
*************** tsubst_decl (tree t, tree args, tree typ
*** 6522,6528 ****
TREE_CHAIN (r) = NULL_TREE;
if (TREE_CODE (r) == VAR_DECL && VOID_TYPE_P (type))
! cp_error_at ("instantiation of `%D' as type `%T'", r, type);
/* Compute the size, alignment, etc. of R. */
layout_decl (r, 0);
}
--- 6525,6531 ----
TREE_CHAIN (r) = NULL_TREE;
if (TREE_CODE (r) == VAR_DECL && VOID_TYPE_P (type))
! cp_error_at ("instantiation of %qD as type %qT", r, type);
/* Compute the size, alignment, etc. of R. */
layout_decl (r, 0);
}
*************** tsubst_arg_types (tree arg_types,
*** 6564,6572 ****
{
if (complain & tf_error)
{
! error ("invalid parameter type `%T'", type);
if (in_decl)
! cp_error_at ("in declaration `%D'", in_decl);
}
return error_mark_node;
}
--- 6567,6575 ----
{
if (complain & tf_error)
{
! error ("invalid parameter type %qT", type);
if (in_decl)
! cp_error_at ("in declaration %qD", in_decl);
}
return error_mark_node;
}
*************** tsubst_function_type (tree t,
*** 6640,6646 ****
-- Attempting to create "pointer to member of T" when T
is not a class type. */
if (complain & tf_error)
! error ("creating pointer to member function of non-class type `%T'",
r);
return error_mark_node;
}
--- 6643,6649 ----
-- Attempting to create "pointer to member of T" when T
is not a class type. */
if (complain & tf_error)
! error ("creating pointer to member function of non-class type %qT",
r);
return error_mark_node;
}
*************** tsubst (tree t, tree args, tsubst_flags_
*** 6791,6797 ****
Attempting to create an array with a size that is
zero or negative. */
if (complain & tf_error)
! error ("creating array with size zero (`%E')", max);
return error_mark_node;
}
--- 6794,6800 ----
Attempting to create an array with a size that is
zero or negative. */
if (complain & tf_error)
! error ("creating array with size zero (%qE)", max);
return error_mark_node;
}
*************** tsubst (tree t, tree args, tsubst_flags_
*** 7010,7018 ****
if (TREE_CODE (type) == VOID_TYPE)
error ("forming reference to void");
else
! error ("forming %s to reference type `%T'",
! (code == POINTER_TYPE) ? "pointer" : "reference",
! type);
last_loc = input_location;
}
--- 7013,7021 ----
if (TREE_CODE (type) == VOID_TYPE)
error ("forming reference to void");
else
! error ("forming %s to reference type %qT",
! (code == POINTER_TYPE) ? "pointer" : "reference",
! type);
last_loc = input_location;
}
*************** tsubst (tree t, tree args, tsubst_flags_
*** 7047,7059 ****
-- Attempting to create "pointer to member of T" when T
is not a class type. */
if (complain & tf_error)
! error ("creating pointer to member of non-class type `%T'", r);
return error_mark_node;
}
if (TREE_CODE (type) == REFERENCE_TYPE)
{
if (complain & tf_error)
! error ("creating pointer to member reference type `%T'", type);
return error_mark_node;
}
--- 7050,7062 ----
-- Attempting to create "pointer to member of T" when T
is not a class type. */
if (complain & tf_error)
! error ("creating pointer to member of non-class type %qT", r);
return error_mark_node;
}
if (TREE_CODE (type) == REFERENCE_TYPE)
{
if (complain & tf_error)
! error ("creating pointer to member reference type %qT", type);
return error_mark_node;
}
*************** tsubst (tree t, tree args, tsubst_flags_
*** 7139,7151 ****
|| TREE_CODE (type) == REFERENCE_TYPE)
{
if (complain & tf_error)
! error ("creating array of `%T'", type);
return error_mark_node;
}
if (CLASS_TYPE_P (type) && CLASSTYPE_PURE_VIRTUALS (type))
{
if (complain & tf_error)
! error ("creating array of `%T', which is an abstract class type",
type);
return error_mark_node;
}
--- 7142,7154 ----
|| TREE_CODE (type) == REFERENCE_TYPE)
{
if (complain & tf_error)
! error ("creating array of %qT", type);
return error_mark_node;
}
if (CLASS_TYPE_P (type) && CLASSTYPE_PURE_VIRTUALS (type))
{
if (complain & tf_error)
! error ("creating array of %qT, which is an abstract class type",
type);
return error_mark_node;
}
*************** tsubst (tree t, tree args, tsubst_flags_
*** 7189,7196 ****
if (!IS_AGGR_TYPE (ctx))
{
if (complain & tf_error)
! error ("`%T' is not a class, struct, or union type",
! ctx);
return error_mark_node;
}
else if (!uses_template_parms (ctx) && !TYPE_BEING_DEFINED (ctx))
--- 7192,7198 ----
if (!IS_AGGR_TYPE (ctx))
{
if (complain & tf_error)
! error ("%qT is not a class, struct, or union type", ctx);
return error_mark_node;
}
else if (!uses_template_parms (ctx) && !TYPE_BEING_DEFINED (ctx))
*************** tsubst_qualified_id (tree qualified_id,
*** 7401,7409 ****
{
if (complain & tf_error)
{
! error ("dependent-name `%E' is parsed as a non-type, but "
"instantiation yields a type", qualified_id);
! inform ("say `typename %E' if a type is meant", qualified_id);
}
return error_mark_node;
}
--- 7403,7411 ----
{
if (complain & tf_error)
{
! error ("dependent-name %qE is parsed as a non-type, but "
"instantiation yields a type", qualified_id);
! inform ("say %<typename %E%> if a type is meant", qualified_id);
}
return error_mark_node;
}
*************** tsubst_copy_and_build (tree t,
*** 8540,8549 ****
if (complain & tf_error)
{
if (TYPE_P (TREE_OPERAND (member, 0)))
! error ("`%T' is not a class or namespace",
TREE_OPERAND (member, 0));
else
! error ("`%D' is not a class or namespace",
TREE_OPERAND (member, 0));
}
return error_mark_node;
--- 8542,8551 ----
if (complain & tf_error)
{
if (TYPE_P (TREE_OPERAND (member, 0)))
! error ("%qT is not a class or namespace",
TREE_OPERAND (member, 0));
else
! error ("%qD is not a class or namespace",
TREE_OPERAND (member, 0));
}
return error_mark_node;
*************** check_instantiated_args (tree tmpl, tree
*** 8668,8676 ****
if (!(complain & tf_error))
/*OK*/;
else if (TYPE_ANONYMOUS_P (nt))
! error ("`%T' uses anonymous type", t);
else
! error ("`%T' uses local type `%T'", t, nt);
result = true;
}
/* In order to avoid all sorts of complications, we do not
--- 8670,8678 ----
if (!(complain & tf_error))
/*OK*/;
else if (TYPE_ANONYMOUS_P (nt))
! error ("%qT uses anonymous type", t);
else
! error ("%qT uses local type %qT", t, nt);
result = true;
}
/* In order to avoid all sorts of complications, we do not
*************** check_instantiated_args (tree tmpl, tree
*** 8678,8684 ****
else if (variably_modified_type_p (t, NULL_TREE))
{
if (complain & tf_error)
! error ("`%T' is a variably modified type", t);
result = true;
}
}
--- 8680,8686 ----
else if (variably_modified_type_p (t, NULL_TREE))
{
if (complain & tf_error)
! error ("%qT is a variably modified type", t);
result = true;
}
}
*************** check_instantiated_args (tree tmpl, tree
*** 8689,8700 ****
&& !TREE_CONSTANT (t))
{
if (complain & tf_error)
! error ("integral expression `%E' is not constant", t);
result = true;
}
}
if (result && complain & tf_error)
! error (" trying to instantiate `%D'", tmpl);
return result;
}
--- 8691,8702 ----
&& !TREE_CONSTANT (t))
{
if (complain & tf_error)
! error ("integral expression %qE is not constant", t);
result = true;
}
}
if (result && complain & tf_error)
! error (" trying to instantiate %qD", tmpl);
return result;
}
*************** do_decl_instantiation (tree decl, tree s
*** 10526,10532 ****
return;
else if (! DECL_LANG_SPECIFIC (decl))
{
! error ("explicit instantiation of non-template `%#D'", decl);
return;
}
else if (TREE_CODE (decl) == VAR_DECL)
--- 10528,10534 ----
return;
else if (! DECL_LANG_SPECIFIC (decl))
{
! error ("explicit instantiation of non-template %q#D", decl);
return;
}
else if (TREE_CODE (decl) == VAR_DECL)
*************** do_decl_instantiation (tree decl, tree s
*** 10542,10554 ****
result = lookup_field (DECL_CONTEXT (decl), DECL_NAME (decl), 0, false);
if (!result || TREE_CODE (result) != VAR_DECL)
{
! error ("no matching template for `%D' found", decl);
return;
}
}
else if (TREE_CODE (decl) != FUNCTION_DECL)
{
! error ("explicit instantiation of `%#D'", decl);
return;
}
else
--- 10544,10556 ----
result = lookup_field (DECL_CONTEXT (decl), DECL_NAME (decl), 0, false);
if (!result || TREE_CODE (result) != VAR_DECL)
{
! error ("no matching template for %qD found", decl);
return;
}
}
else if (TREE_CODE (decl) != FUNCTION_DECL)
{
! error ("explicit instantiation of %q#D", decl);
return;
}
else
*************** do_decl_instantiation (tree decl, tree s
*** 10584,10590 ****
the first instantiation was `extern' and the second is not,
and EXTERN_P for the opposite case. */
if (DECL_NOT_REALLY_EXTERN (result) && !extern_p)
! pedwarn ("duplicate explicit instantiation of `%#D'", result);
/* If an "extern" explicit instantiation follows an ordinary
explicit instantiation, the template is instantiated. */
if (extern_p)
--- 10586,10592 ----
the first instantiation was `extern' and the second is not,
and EXTERN_P for the opposite case. */
if (DECL_NOT_REALLY_EXTERN (result) && !extern_p)
! pedwarn ("duplicate explicit instantiation of %q#D", result);
/* If an "extern" explicit instantiation follows an ordinary
explicit instantiation, the template is instantiated. */
if (extern_p)
*************** do_decl_instantiation (tree decl, tree s
*** 10592,10603 ****
}
else if (!DECL_IMPLICIT_INSTANTIATION (result))
{
! error ("no matching template for `%D' found", result);
return;
}
else if (!DECL_TEMPLATE_INFO (result))
{
! pedwarn ("explicit instantiation of non-template `%#D'", result);
return;
}
--- 10594,10605 ----
}
else if (!DECL_IMPLICIT_INSTANTIATION (result))
{
! error ("no matching template for %qD found", result);
return;
}
else if (!DECL_TEMPLATE_INFO (result))
{
! pedwarn ("explicit instantiation of non-template %q#D", result);
return;
}
*************** do_decl_instantiation (tree decl, tree s
*** 10606,10617 ****
else if (storage == ridpointers[(int) RID_EXTERN])
{
if (pedantic && !in_system_header)
! pedwarn ("ISO C++ forbids the use of `extern' on explicit instantiations");
extern_p = 1;
}
else
! error ("storage class `%D' applied to template instantiation",
! storage);
mark_decl_instantiated (result, extern_p);
if (! extern_p)
--- 10608,10619 ----
else if (storage == ridpointers[(int) RID_EXTERN])
{
if (pedantic && !in_system_header)
! pedwarn ("ISO C++ forbids the use of %<extern%> on explicit "
! "instantiations");
extern_p = 1;
}
else
! error ("storage class %qD applied to template instantiation", storage);
mark_decl_instantiated (result, extern_p);
if (! extern_p)
*************** do_type_instantiation (tree t, tree stor
*** 10673,10679 ****
if (! CLASS_TYPE_P (t) || ! CLASSTYPE_TEMPLATE_INFO (t))
{
! error ("explicit instantiation of non-template type `%T'", t);
return;
}
--- 10675,10681 ----
if (! CLASS_TYPE_P (t) || ! CLASSTYPE_TEMPLATE_INFO (t))
{
! error ("explicit instantiation of non-template type %qT", t);
return;
}
*************** do_type_instantiation (tree t, tree stor
*** 10682,10689 ****
if (!COMPLETE_TYPE_P (t))
{
if (complain & tf_error)
! error ("explicit instantiation of `%#T' before definition of template",
! t);
return;
}
--- 10684,10691 ----
if (!COMPLETE_TYPE_P (t))
{
if (complain & tf_error)
! error ("explicit instantiation of %q#T before definition of template",
! t);
return;
}
*************** do_type_instantiation (tree t, tree stor
*** 10701,10708 ****
static_p = 1;
else
{
! error ("storage class `%D' applied to template instantiation",
! storage);
extern_p = 0;
}
}
--- 10703,10710 ----
static_p = 1;
else
{
! error ("storage class %qD applied to template instantiation",
! storage);
extern_p = 0;
}
}
*************** do_type_instantiation (tree t, tree stor
*** 10735,10741 ****
if (!previous_instantiation_extern_p && !extern_p
&& (complain & tf_error))
! pedwarn ("duplicate explicit instantiation of `%#T'", t);
/* If we've already instantiated the template, just return now. */
if (!CLASSTYPE_INTERFACE_ONLY (t))
--- 10737,10743 ----
if (!previous_instantiation_extern_p && !extern_p
&& (complain & tf_error))
! pedwarn ("duplicate explicit instantiation of %q#T", t);
/* If we've already instantiated the template, just return now. */
if (!CLASSTYPE_INTERFACE_ONLY (t))
*************** instantiate_decl (tree d, int defer_ok,
*** 11098,11104 ****
shall be present in every translation unit in which it is
explicitly instantiated. */
pedwarn
! ("explicit instantiation of `%D' but no definition available", d);
add_pending_template (d);
goto out;
--- 11100,11106 ----
shall be present in every translation unit in which it is
explicitly instantiated. */
pedwarn
! ("explicit instantiation of %qD but no definition available", d);
add_pending_template (d);
goto out;
*************** instantiate_pending_templates (int retri
*** 11244,11250 ****
{
cp_error_at ("template instantiation depth exceeds maximum of %d"
" (use -ftemplate-depth-NN to increase the maximum)"
! " instantiating `%+D', possibly from virtual table"
" generation",
max_tinst_depth, TREE_VALUE (pending_templates));
return;
--- 11246,11252 ----
{
cp_error_at ("template instantiation depth exceeds maximum of %d"
" (use -ftemplate-depth-NN to increase the maximum)"
! " instantiating %q+D, possibly from virtual table"
" generation",
max_tinst_depth, TREE_VALUE (pending_templates));
return;
*************** invalid_nontype_parm_type_p (tree type,
*** 11521,11528 ****
return 0;
if (complain & tf_error)
! error ("`%#T' is not a valid type for a template constant parameter",
! type);
return 1;
}
--- 11523,11529 ----
return 0;
if (complain & tf_error)
! error ("%q#T is not a valid type for a template constant parameter", type);
return 1;
}