From 10f3742b1103aa2840c74719a4791b337e2fa0f7 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Sat, 4 Feb 2006 16:44:18 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 20 ++++++++++++++++++++ gcc/cp/call.c | 2 +- gcc/cp/cp-tree.h | 6 ++++-- gcc/cp/cvt.c | 4 ++-- gcc/cp/decl.c | 4 ++-- gcc/cp/pt.c | 39 +++++++++++++++++++-------------------- gcc/cp/semantics.c | 2 +- gcc/cp/typeck.c | 4 ++-- 8 files changed, 51 insertions(+), 30 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 63e5f9aecdc..e1737e90e89 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,23 @@ +2006-02-04 Gabriel Dos Reis + + * 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 * typeck.c (string_conv_p): Pass appropiate diff --git a/gcc/cp/call.c b/gcc/cp/call.c index b5998fa13e5..0613f2789e4 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4279,7 +4279,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, } case ck_identity: 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 about to bind it to a reference, in which case we need to leave it as an lvalue. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 7227083b7c3..c74ad9db8fe 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3108,10 +3108,12 @@ typedef enum tsubst_flags_t { instantiate_type use) */ tf_user = 1 << 5, /* found template must be a user template (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, not actually performing the conversion. */ + /* Convenient substitution flags combinations. */ + tf_warn_or_error = tf_warning | tf_error } tsubst_flags_t; /* The kind of checking we can do looking in a class hierarchy. */ @@ -4274,7 +4276,7 @@ extern tree make_ptrmem_cst (tree, tree); extern tree cp_build_type_attribute_variant (tree, tree); extern tree cp_build_qualified_type_real (tree, int, tsubst_flags_t); #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 int count_trees (tree); extern int char_type_p (tree); diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index ef121d2c3e9..ddb011cb5c4 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -280,7 +280,7 @@ cp_convert_to_pointer (tree type, tree expr, bool force) } 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", expr, intype, type); @@ -451,7 +451,7 @@ convert_to_reference (tree reftype, tree expr, int convtype, && TREE_TYPE (expr) == unknown_type_node) expr = instantiate_type (type, expr, (flags & LOOKUP_COMPLAIN) - ? tf_error | tf_warning : tf_none); + ? tf_warn_or_error : tf_none); if (expr == error_mark_node) return error_mark_node; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6e2abf8f3dd..5aab8b1ab9d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2672,7 +2672,7 @@ make_typename_type (tree context, tree name, enum tag_types tag_type, TREE_OPERAND (fullname, 1), NULL_TREE, context, /*entering_scope=*/0, - tf_error | tf_warning | tf_user); + tf_warn_or_error | tf_user); } else { @@ -7113,7 +7113,7 @@ grokdeclarator (const cp_declarator *declarator, type_quals |= cp_type_quals (type); type = cp_build_qualified_type_real (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. */ type_quals = cp_type_quals (type); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 63277e59964..aac7f3ca22a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5149,13 +5149,13 @@ tsubst_friend_function (tree decl, tree args) current cless with same name. */ push_nested_namespace (ns); fns = tsubst_expr (DECL_TI_TEMPLATE (decl), args, - tf_error | tf_warning, NULL_TREE); + tf_warn_or_error, NULL_TREE); pop_nested_namespace (ns); 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); - 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, &new_args, /*need_member_template=*/0, @@ -5163,7 +5163,7 @@ tsubst_friend_function (tree decl, tree args) 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 compiler, but is not an instantiation from the point of view of @@ -5416,7 +5416,7 @@ tsubst_friend_class (tree friend_tmpl, tree args) { tree parms; 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); } @@ -5427,7 +5427,7 @@ tsubst_friend_class (tree friend_tmpl, tree args) /* The friend template has not already been declared. In this case, the instantiation of the template class will cause the 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 forget its origins. We don't reset CLASSTYPE_TI_TEMPLATE for @@ -5719,7 +5719,7 @@ instantiate_class_template (tree type) if (TREE_CODE (t) == 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) --processing_template_decl; if (TREE_CODE (r) == VAR_DECL) @@ -5793,7 +5793,7 @@ instantiate_class_template (tree type) { /* template friend class C::D; */ 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) friend_type = TREE_TYPE (friend_type); adjust_processing_template_decl = true; @@ -5810,7 +5810,7 @@ instantiate_class_template (tree type) otherwise. */ friend_type = tsubst (friend_type, args, - tf_error | tf_warning, NULL_TREE); + tf_warn_or_error, NULL_TREE); /* Bump processing_template_decl for correct dependent_type_p calculation. */ ++processing_template_decl; @@ -5839,7 +5839,7 @@ instantiate_class_template (tree type) else if (uses_template_parms (friend_type)) /* friend class C; */ friend_type = tsubst (friend_type, args, - tf_error | tf_warning, NULL_TREE); + tf_warn_or_error, NULL_TREE); /* Otherwise it's friend class C; @@ -6148,7 +6148,7 @@ tsubst_default_argument (tree fn, tree type, tree arg) push_deferring_access_checks(dk_no_deferred); arg = tsubst_expr (arg, DECL_TI_ARGS (fn), - tf_error | tf_warning, NULL_TREE); + tf_warn_or_error, NULL_TREE); pop_deferring_access_checks(); /* Restore the "this" pointer. */ @@ -11606,16 +11606,16 @@ instantiate_decl (tree d, int defer_ok, 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, - tf_error | tf_warning, d); + tf_warn_or_error, d); /* Don't simply tsubst the function type, as that will give duplicate warnings about poor parameter qualifications. The function arguments are the same as the decl_arguments without the top level cv qualifiers. */ 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); } @@ -11661,7 +11661,7 @@ instantiate_decl (tree d, int defer_ok, push_nested_class (DECL_CONTEXT (d)); init = tsubst_expr (DECL_INITIAL (code_pattern), args, - tf_error | tf_warning, NULL_TREE); + tf_warn_or_error, NULL_TREE); DECL_INITIAL (d) = init; cp_finish_decl (d, init, /*asmspec_tree=*/NULL_TREE, LOOKUP_ONLYCONVERTING); @@ -11783,7 +11783,7 @@ instantiate_decl (tree d, int defer_ok, /* Substitute into the body of the function. */ 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. */ htab_delete (local_specializations); @@ -11930,13 +11930,13 @@ tsubst_initializer_list (tree t, tree argvec) tree decl; 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); decl = expand_member_init (decl); if (decl && !DECL_P (decl)) 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); in_base_initializer = 0; @@ -11981,8 +11981,7 @@ tsubst_enum (tree tag, tree newtag, tree args) /* Note that in a template enum, the TREE_VALUE is the CONST_DECL, not the corresponding INTEGER_CST. */ value = tsubst_expr (DECL_INITIAL (decl), - args, tf_error | tf_warning, - NULL_TREE); + args, tf_warn_or_error, NULL_TREE); /* Give this enumeration constant the correct access. */ set_current_access_from_decl (decl); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 82218995774..981c16b9275 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2324,7 +2324,7 @@ finish_template_type (tree name, tree args, int entering_scope) decl = lookup_template_class (name, args, NULL_TREE, NULL_TREE, entering_scope, - tf_error | tf_warning | tf_user); + tf_warn_or_error | tf_user); if (decl != error_mark_node) decl = TYPE_STUB_DECL (decl); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 95247c490af..1fb3cbf7915 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5878,7 +5878,7 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p) } 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); gcc_assert (TREE_CODE (fn) == FUNCTION_DECL @@ -6069,7 +6069,7 @@ convert_for_assignment (tree type, tree rhs, overloaded function. Call instantiate_type to get error messages. */ if (rhstype == unknown_type_node) - instantiate_type (type, rhs, tf_error | tf_warning); + instantiate_type (type, rhs, tf_warn_or_error); else if (fndecl) error ("cannot convert %qT to %qT for argument %qP to %qD", rhstype, type, parmnum, fndecl); -- 2.30.2