Commit 10f3742b by Gabriel Dos Reis Committed by Gabriel Dos Reis

cp-tree.h (tf_warn_or_error): New substituion flag.

        * cp-tree.h (tf_warn_or_error): New substituion flag.
        (cp_build_qualified_type): Use it.
        * call.c (convert_like_real): Likewise.
        * cvt.c (cp_convert_to_pointer): Likewise.
        (convert_to_reference): Likewise.
        * decl.c (make_typename_type): Likewise.
        (grokdeclarator): Likewise.
        * pt.c (tsubst_friend_function): Likewise.
        (tsubst_friend_class): Likewise.
        (instantiate_class_template): Likewise.
        (tsubst_default_argument): Likewise.
        (instantiate_decl): Likewise.
        (tsubst_initializer_list): Likewise.
        (tsubst_enum): Likewise.
        * semantics.c (finish_template_type): Likewise.
        * typeck.c (build_ptrmemfunc): Likewise.
        (convert_for_assignment): Likewise.

From-SVN: r110590
parent 337bde91
2006-02-04 Gabriel Dos Reis <gdr@integrable-solutions.net>
* cp-tree.h (tf_warn_or_error): New substituion flag.
(cp_build_qualified_type): Use it.
* call.c (convert_like_real): Likewise.
* cvt.c (cp_convert_to_pointer): Likewise.
(convert_to_reference): Likewise.
* decl.c (make_typename_type): Likewise.
(grokdeclarator): Likewise.
* pt.c (tsubst_friend_function): Likewise.
(tsubst_friend_class): Likewise.
(instantiate_class_template): Likewise.
(tsubst_default_argument): Likewise.
(instantiate_decl): Likewise.
(tsubst_initializer_list): Likewise.
(tsubst_enum): Likewise.
* semantics.c (finish_template_type): Likewise.
* typeck.c (build_ptrmemfunc): Likewise.
(convert_for_assignment): Likewise.
2006-02-03 Lee Millward <lee.millward@gmail.com> 2006-02-03 Lee Millward <lee.millward@gmail.com>
* typeck.c (string_conv_p): Pass appropiate * typeck.c (string_conv_p): Pass appropiate
......
...@@ -4279,7 +4279,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, ...@@ -4279,7 +4279,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
} }
case ck_identity: case ck_identity:
if (type_unknown_p (expr)) if (type_unknown_p (expr))
expr = instantiate_type (totype, expr, tf_error | tf_warning); expr = instantiate_type (totype, expr, tf_warn_or_error);
/* Convert a constant to its underlying value, unless we are /* Convert a constant to its underlying value, unless we are
about to bind it to a reference, in which case we need to about to bind it to a reference, in which case we need to
leave it as an lvalue. */ leave it as an lvalue. */
......
...@@ -3108,10 +3108,12 @@ typedef enum tsubst_flags_t { ...@@ -3108,10 +3108,12 @@ typedef enum tsubst_flags_t {
instantiate_type use) */ instantiate_type use) */
tf_user = 1 << 5, /* found template must be a user template tf_user = 1 << 5, /* found template must be a user template
(lookup_template_class use) */ (lookup_template_class use) */
tf_conv = 1 << 6 /* We are determining what kind of tf_conv = 1 << 6, /* We are determining what kind of
conversion might be permissible, conversion might be permissible,
not actually performing the not actually performing the
conversion. */ conversion. */
/* Convenient substitution flags combinations. */
tf_warn_or_error = tf_warning | tf_error
} tsubst_flags_t; } tsubst_flags_t;
/* The kind of checking we can do looking in a class hierarchy. */ /* The kind of checking we can do looking in a class hierarchy. */
...@@ -4274,7 +4276,7 @@ extern tree make_ptrmem_cst (tree, tree); ...@@ -4274,7 +4276,7 @@ extern tree make_ptrmem_cst (tree, tree);
extern tree cp_build_type_attribute_variant (tree, tree); extern tree cp_build_type_attribute_variant (tree, tree);
extern tree cp_build_qualified_type_real (tree, int, tsubst_flags_t); extern tree cp_build_qualified_type_real (tree, int, tsubst_flags_t);
#define cp_build_qualified_type(TYPE, QUALS) \ #define cp_build_qualified_type(TYPE, QUALS) \
cp_build_qualified_type_real ((TYPE), (QUALS), tf_error | tf_warning) cp_build_qualified_type_real ((TYPE), (QUALS), tf_warn_or_error)
extern special_function_kind special_function_p (tree); extern special_function_kind special_function_p (tree);
extern int count_trees (tree); extern int count_trees (tree);
extern int char_type_p (tree); extern int char_type_p (tree);
......
...@@ -280,7 +280,7 @@ cp_convert_to_pointer (tree type, tree expr, bool force) ...@@ -280,7 +280,7 @@ cp_convert_to_pointer (tree type, tree expr, bool force)
} }
if (type_unknown_p (expr)) if (type_unknown_p (expr))
return instantiate_type (type, expr, tf_error | tf_warning); return instantiate_type (type, expr, tf_warn_or_error);
error ("cannot convert %qE from type %qT to type %qT", error ("cannot convert %qE from type %qT to type %qT",
expr, intype, type); expr, intype, type);
...@@ -451,7 +451,7 @@ convert_to_reference (tree reftype, tree expr, int convtype, ...@@ -451,7 +451,7 @@ convert_to_reference (tree reftype, tree expr, int convtype,
&& TREE_TYPE (expr) == unknown_type_node) && TREE_TYPE (expr) == unknown_type_node)
expr = instantiate_type (type, expr, expr = instantiate_type (type, expr,
(flags & LOOKUP_COMPLAIN) (flags & LOOKUP_COMPLAIN)
? tf_error | tf_warning : tf_none); ? tf_warn_or_error : tf_none);
if (expr == error_mark_node) if (expr == error_mark_node)
return error_mark_node; return error_mark_node;
......
...@@ -2672,7 +2672,7 @@ make_typename_type (tree context, tree name, enum tag_types tag_type, ...@@ -2672,7 +2672,7 @@ make_typename_type (tree context, tree name, enum tag_types tag_type,
TREE_OPERAND (fullname, 1), TREE_OPERAND (fullname, 1),
NULL_TREE, context, NULL_TREE, context,
/*entering_scope=*/0, /*entering_scope=*/0,
tf_error | tf_warning | tf_user); tf_warn_or_error | tf_user);
} }
else else
{ {
...@@ -7113,7 +7113,7 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -7113,7 +7113,7 @@ grokdeclarator (const cp_declarator *declarator,
type_quals |= cp_type_quals (type); type_quals |= cp_type_quals (type);
type = cp_build_qualified_type_real type = cp_build_qualified_type_real
(type, type_quals, ((typedef_decl && !DECL_ARTIFICIAL (typedef_decl) (type, type_quals, ((typedef_decl && !DECL_ARTIFICIAL (typedef_decl)
? tf_ignore_bad_quals : 0) | tf_error | tf_warning)); ? tf_ignore_bad_quals : 0) | tf_warn_or_error));
/* We might have ignored or rejected some of the qualifiers. */ /* We might have ignored or rejected some of the qualifiers. */
type_quals = cp_type_quals (type); type_quals = cp_type_quals (type);
......
...@@ -5149,13 +5149,13 @@ tsubst_friend_function (tree decl, tree args) ...@@ -5149,13 +5149,13 @@ tsubst_friend_function (tree decl, tree args)
current cless with same name. */ current cless with same name. */
push_nested_namespace (ns); push_nested_namespace (ns);
fns = tsubst_expr (DECL_TI_TEMPLATE (decl), args, fns = tsubst_expr (DECL_TI_TEMPLATE (decl), args,
tf_error | tf_warning, NULL_TREE); tf_warn_or_error, NULL_TREE);
pop_nested_namespace (ns); pop_nested_namespace (ns);
arglist = tsubst (DECL_TI_ARGS (decl), args, arglist = tsubst (DECL_TI_ARGS (decl), args,
tf_error | tf_warning, NULL_TREE); tf_warn_or_error, NULL_TREE);
template_id = lookup_template_function (fns, arglist); template_id = lookup_template_function (fns, arglist);
new_friend = tsubst (decl, args, tf_error | tf_warning, NULL_TREE); new_friend = tsubst (decl, args, tf_warn_or_error, NULL_TREE);
tmpl = determine_specialization (template_id, new_friend, tmpl = determine_specialization (template_id, new_friend,
&new_args, &new_args,
/*need_member_template=*/0, /*need_member_template=*/0,
...@@ -5163,7 +5163,7 @@ tsubst_friend_function (tree decl, tree args) ...@@ -5163,7 +5163,7 @@ tsubst_friend_function (tree decl, tree args)
return instantiate_template (tmpl, new_args, tf_error); return instantiate_template (tmpl, new_args, tf_error);
} }
new_friend = tsubst (decl, args, tf_error | tf_warning, NULL_TREE); new_friend = tsubst (decl, args, tf_warn_or_error, NULL_TREE);
/* The NEW_FRIEND will look like an instantiation, to the /* The NEW_FRIEND will look like an instantiation, to the
compiler, but is not an instantiation from the point of view of compiler, but is not an instantiation from the point of view of
...@@ -5416,7 +5416,7 @@ tsubst_friend_class (tree friend_tmpl, tree args) ...@@ -5416,7 +5416,7 @@ tsubst_friend_class (tree friend_tmpl, tree args)
{ {
tree parms; tree parms;
parms = tsubst_template_parms (DECL_TEMPLATE_PARMS (friend_tmpl), parms = tsubst_template_parms (DECL_TEMPLATE_PARMS (friend_tmpl),
args, tf_error | tf_warning); args, tf_warn_or_error);
redeclare_class_template (TREE_TYPE (tmpl), parms); redeclare_class_template (TREE_TYPE (tmpl), parms);
} }
...@@ -5427,7 +5427,7 @@ tsubst_friend_class (tree friend_tmpl, tree args) ...@@ -5427,7 +5427,7 @@ tsubst_friend_class (tree friend_tmpl, tree args)
/* The friend template has not already been declared. In this /* The friend template has not already been declared. In this
case, the instantiation of the template class will cause the case, the instantiation of the template class will cause the
injection of this template into the global scope. */ injection of this template into the global scope. */
tmpl = tsubst (friend_tmpl, args, tf_error | tf_warning, NULL_TREE); tmpl = tsubst (friend_tmpl, args, tf_warn_or_error, NULL_TREE);
/* The new TMPL is not an instantiation of anything, so we /* The new TMPL is not an instantiation of anything, so we
forget its origins. We don't reset CLASSTYPE_TI_TEMPLATE for forget its origins. We don't reset CLASSTYPE_TI_TEMPLATE for
...@@ -5719,7 +5719,7 @@ instantiate_class_template (tree type) ...@@ -5719,7 +5719,7 @@ instantiate_class_template (tree type)
if (TREE_CODE (t) == TEMPLATE_DECL) if (TREE_CODE (t) == TEMPLATE_DECL)
++processing_template_decl; ++processing_template_decl;
r = tsubst (t, args, tf_error | tf_warning, NULL_TREE); r = tsubst (t, args, tf_warn_or_error, NULL_TREE);
if (TREE_CODE (t) == TEMPLATE_DECL) if (TREE_CODE (t) == TEMPLATE_DECL)
--processing_template_decl; --processing_template_decl;
if (TREE_CODE (r) == VAR_DECL) if (TREE_CODE (r) == VAR_DECL)
...@@ -5793,7 +5793,7 @@ instantiate_class_template (tree type) ...@@ -5793,7 +5793,7 @@ instantiate_class_template (tree type)
{ {
/* template <class T> friend class C::D; */ /* template <class T> friend class C::D; */
friend_type = tsubst (friend_type, args, friend_type = tsubst (friend_type, args,
tf_error | tf_warning, NULL_TREE); tf_warn_or_error, NULL_TREE);
if (TREE_CODE (friend_type) == TEMPLATE_DECL) if (TREE_CODE (friend_type) == TEMPLATE_DECL)
friend_type = TREE_TYPE (friend_type); friend_type = TREE_TYPE (friend_type);
adjust_processing_template_decl = true; adjust_processing_template_decl = true;
...@@ -5810,7 +5810,7 @@ instantiate_class_template (tree type) ...@@ -5810,7 +5810,7 @@ instantiate_class_template (tree type)
otherwise. */ otherwise. */
friend_type = tsubst (friend_type, args, friend_type = tsubst (friend_type, args,
tf_error | tf_warning, NULL_TREE); tf_warn_or_error, NULL_TREE);
/* Bump processing_template_decl for correct /* Bump processing_template_decl for correct
dependent_type_p calculation. */ dependent_type_p calculation. */
++processing_template_decl; ++processing_template_decl;
...@@ -5839,7 +5839,7 @@ instantiate_class_template (tree type) ...@@ -5839,7 +5839,7 @@ instantiate_class_template (tree type)
else if (uses_template_parms (friend_type)) else if (uses_template_parms (friend_type))
/* friend class C<T>; */ /* friend class C<T>; */
friend_type = tsubst (friend_type, args, friend_type = tsubst (friend_type, args,
tf_error | tf_warning, NULL_TREE); tf_warn_or_error, NULL_TREE);
/* Otherwise it's /* Otherwise it's
friend class C; friend class C;
...@@ -6148,7 +6148,7 @@ tsubst_default_argument (tree fn, tree type, tree arg) ...@@ -6148,7 +6148,7 @@ tsubst_default_argument (tree fn, tree type, tree arg)
push_deferring_access_checks(dk_no_deferred); push_deferring_access_checks(dk_no_deferred);
arg = tsubst_expr (arg, DECL_TI_ARGS (fn), arg = tsubst_expr (arg, DECL_TI_ARGS (fn),
tf_error | tf_warning, NULL_TREE); tf_warn_or_error, NULL_TREE);
pop_deferring_access_checks(); pop_deferring_access_checks();
/* Restore the "this" pointer. */ /* Restore the "this" pointer. */
...@@ -11606,16 +11606,16 @@ instantiate_decl (tree d, int defer_ok, ...@@ -11606,16 +11606,16 @@ instantiate_decl (tree d, int defer_ok,
if (TREE_CODE (gen) == FUNCTION_DECL) if (TREE_CODE (gen) == FUNCTION_DECL)
{ {
tsubst (DECL_ARGUMENTS (gen), gen_args, tf_error | tf_warning, d); tsubst (DECL_ARGUMENTS (gen), gen_args, tf_warn_or_error, d);
tsubst (TYPE_RAISES_EXCEPTIONS (type), gen_args, tsubst (TYPE_RAISES_EXCEPTIONS (type), gen_args,
tf_error | tf_warning, d); tf_warn_or_error, d);
/* Don't simply tsubst the function type, as that will give /* Don't simply tsubst the function type, as that will give
duplicate warnings about poor parameter qualifications. duplicate warnings about poor parameter qualifications.
The function arguments are the same as the decl_arguments The function arguments are the same as the decl_arguments
without the top level cv qualifiers. */ without the top level cv qualifiers. */
type = TREE_TYPE (type); type = TREE_TYPE (type);
} }
tsubst (type, gen_args, tf_error | tf_warning, d); tsubst (type, gen_args, tf_warn_or_error, d);
pop_access_scope (d); pop_access_scope (d);
} }
...@@ -11661,7 +11661,7 @@ instantiate_decl (tree d, int defer_ok, ...@@ -11661,7 +11661,7 @@ instantiate_decl (tree d, int defer_ok,
push_nested_class (DECL_CONTEXT (d)); push_nested_class (DECL_CONTEXT (d));
init = tsubst_expr (DECL_INITIAL (code_pattern), init = tsubst_expr (DECL_INITIAL (code_pattern),
args, args,
tf_error | tf_warning, NULL_TREE); tf_warn_or_error, NULL_TREE);
DECL_INITIAL (d) = init; DECL_INITIAL (d) = init;
cp_finish_decl (d, init, /*asmspec_tree=*/NULL_TREE, cp_finish_decl (d, init, /*asmspec_tree=*/NULL_TREE,
LOOKUP_ONLYCONVERTING); LOOKUP_ONLYCONVERTING);
...@@ -11783,7 +11783,7 @@ instantiate_decl (tree d, int defer_ok, ...@@ -11783,7 +11783,7 @@ instantiate_decl (tree d, int defer_ok,
/* Substitute into the body of the function. */ /* Substitute into the body of the function. */
tsubst_expr (DECL_SAVED_TREE (code_pattern), args, tsubst_expr (DECL_SAVED_TREE (code_pattern), args,
tf_error | tf_warning, tmpl); tf_warn_or_error, tmpl);
/* We don't need the local specializations any more. */ /* We don't need the local specializations any more. */
htab_delete (local_specializations); htab_delete (local_specializations);
...@@ -11930,13 +11930,13 @@ tsubst_initializer_list (tree t, tree argvec) ...@@ -11930,13 +11930,13 @@ tsubst_initializer_list (tree t, tree argvec)
tree decl; tree decl;
tree init; tree init;
decl = tsubst_copy (TREE_PURPOSE (t), argvec, tf_error | tf_warning, decl = tsubst_copy (TREE_PURPOSE (t), argvec, tf_warn_or_error,
NULL_TREE); NULL_TREE);
decl = expand_member_init (decl); decl = expand_member_init (decl);
if (decl && !DECL_P (decl)) if (decl && !DECL_P (decl))
in_base_initializer = 1; in_base_initializer = 1;
init = tsubst_expr (TREE_VALUE (t), argvec, tf_error | tf_warning, init = tsubst_expr (TREE_VALUE (t), argvec, tf_warn_or_error,
NULL_TREE); NULL_TREE);
in_base_initializer = 0; in_base_initializer = 0;
...@@ -11981,8 +11981,7 @@ tsubst_enum (tree tag, tree newtag, tree args) ...@@ -11981,8 +11981,7 @@ tsubst_enum (tree tag, tree newtag, tree args)
/* Note that in a template enum, the TREE_VALUE is the /* Note that in a template enum, the TREE_VALUE is the
CONST_DECL, not the corresponding INTEGER_CST. */ CONST_DECL, not the corresponding INTEGER_CST. */
value = tsubst_expr (DECL_INITIAL (decl), value = tsubst_expr (DECL_INITIAL (decl),
args, tf_error | tf_warning, args, tf_warn_or_error, NULL_TREE);
NULL_TREE);
/* Give this enumeration constant the correct access. */ /* Give this enumeration constant the correct access. */
set_current_access_from_decl (decl); set_current_access_from_decl (decl);
......
...@@ -2324,7 +2324,7 @@ finish_template_type (tree name, tree args, int entering_scope) ...@@ -2324,7 +2324,7 @@ finish_template_type (tree name, tree args, int entering_scope)
decl = lookup_template_class (name, args, decl = lookup_template_class (name, args,
NULL_TREE, NULL_TREE, entering_scope, NULL_TREE, NULL_TREE, entering_scope,
tf_error | tf_warning | tf_user); tf_warn_or_error | tf_user);
if (decl != error_mark_node) if (decl != error_mark_node)
decl = TYPE_STUB_DECL (decl); decl = TYPE_STUB_DECL (decl);
......
...@@ -5878,7 +5878,7 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p) ...@@ -5878,7 +5878,7 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p)
} }
if (type_unknown_p (pfn)) if (type_unknown_p (pfn))
return instantiate_type (type, pfn, tf_error | tf_warning); return instantiate_type (type, pfn, tf_warn_or_error);
fn = TREE_OPERAND (pfn, 0); fn = TREE_OPERAND (pfn, 0);
gcc_assert (TREE_CODE (fn) == FUNCTION_DECL gcc_assert (TREE_CODE (fn) == FUNCTION_DECL
...@@ -6069,7 +6069,7 @@ convert_for_assignment (tree type, tree rhs, ...@@ -6069,7 +6069,7 @@ convert_for_assignment (tree type, tree rhs,
overloaded function. Call instantiate_type to get error overloaded function. Call instantiate_type to get error
messages. */ messages. */
if (rhstype == unknown_type_node) if (rhstype == unknown_type_node)
instantiate_type (type, rhs, tf_error | tf_warning); instantiate_type (type, rhs, tf_warn_or_error);
else if (fndecl) else if (fndecl)
error ("cannot convert %qT to %qT for argument %qP to %qD", error ("cannot convert %qT to %qT for argument %qP to %qD",
rhstype, type, parmnum, fndecl); rhstype, type, parmnum, fndecl);
......
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