From patchwork Thu Apr 11 14:44:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 235776 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D4AB82C00B9 for ; Fri, 12 Apr 2013 00:44:18 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=avS6siEz8KZJDWNvDipOEbcrm768PzHTb5jndcqMItM 8SI+kDGTnhCF4F3Vk8lOX8cMch48dm/FrwZslrOUaClVsRjNhQPt2HMg7WQDJt1e b8vurzF7BP2DyjHp2e+bgVcj1Do69zUKHOd8FPBQdq8txkti4x7GxU7Nu2iBlcZE = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=3GezcLhR636wsdzenAk2MjTWo9A=; b=QZngZ8AJiY6JcX6ZL 8I0a6tXd8CUT4IwQBA2WwMh/AH2g7RvxjJ2MlCuTjseQuIYuBU+xVRvuSYaqJyj0 JuZsHwyWjm85BGHxhMS/4vjUhmeVbRg/3rihGwGkMS+q8tjPwh5UphtpAzDpqWh/ WYwKGhlvCsG/Juhqn82lRhgKf0= Received: (qmail 2121 invoked by alias); 11 Apr 2013 14:44:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2110 invoked by uid 89); 11 Apr 2013 14:44:11 -0000 X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 11 Apr 2013 14:44:10 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r3BEi7w7022257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 11 Apr 2013 14:44:08 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3BEi7Hk008611 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 11 Apr 2013 14:44:07 GMT Received: from abhmt118.oracle.com (abhmt118.oracle.com [141.146.116.70]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3BEi6tt008583; Thu, 11 Apr 2013 14:44:06 GMT Received: from [192.168.1.4] (/79.33.220.128) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Apr 2013 07:44:06 -0700 Message-ID: <5166CC34.10305@oracle.com> Date: Thu, 11 Apr 2013 16:44:04 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] Small bunch of SFINAE related fixes X-Virus-Found: No Hi, while working on the last patch I noticed that we have got quite a few unconditional error calls in functions taking a tusbst_flags_t parameter. The below mostly adjusts those. I'm also finding a bit misleading the name warn_ref_binding for a the function emitting a permerror, thus I'm changing it and consistently protecting the calls with tf_error instead of tf_warning. I'm finishing testing on x86_64-linux, Ok if it pases? Thanks, Paolo. /////////////////////// 2013-04-11 Paolo Carlini * call.c (build_conditional_expr_1, build_over_call): Protect error calls with complain & tf_error. * typeck.c (finish_class_member_access_expr, cp_build_binary_op, build_x_unary_op, cp_build_unary_op, cp_build_compound_expr, build_ptrmemfunc): Likewise. (lookup_destructor): Take tsubst_flags_t parameter, adjust. * cvt.c (warn_ref_binding): Rename to diagnose_ref_binding. (convert_to_reference): Adjust. Index: call.c =================================================================== --- call.c (revision 197804) +++ call.c (working copy) @@ -4577,8 +4577,9 @@ build_conditional_expr_1 (tree arg1, tree arg2, tr || (conv2 && conv2->kind == ck_ambig) || (conv3 && conv3->kind == ck_ambig)) { - error ("operands to ?: have different types %qT and %qT", - arg2_type, arg3_type); + if (complain & tf_error) + error ("operands to ?: have different types %qT and %qT", + arg2_type, arg3_type); result = error_mark_node; } else if (conv2 && (!conv2->bad_p || !conv3)) @@ -4760,10 +4761,11 @@ build_conditional_expr_1 (tree arg1, tree arg2, tr /* In this case, there is always a common type. */ result_type = type_after_usual_arithmetic_conversions (arg2_type, arg3_type); - do_warn_double_promotion (result_type, arg2_type, arg3_type, - "implicit conversion from %qT to %qT to " - "match other result of conditional", - input_location); + if (complain & tf_warning) + do_warn_double_promotion (result_type, arg2_type, arg3_type, + "implicit conversion from %qT to %qT to " + "match other result of conditional", + input_location); if (TREE_CODE (arg2_type) == ENUMERAL_TYPE && TREE_CODE (arg3_type) == ENUMERAL_TYPE) @@ -6790,9 +6792,14 @@ build_over_call (struct z_candidate *cand, int fla /* Check that the base class is accessible. */ if (!accessible_base_p (TREE_TYPE (argtype), BINFO_TYPE (cand->conversion_path), true)) - error ("%qT is not an accessible base of %qT", - BINFO_TYPE (cand->conversion_path), - TREE_TYPE (argtype)); + { + if (complain & tf_error) + error ("%qT is not an accessible base of %qT", + BINFO_TYPE (cand->conversion_path), + TREE_TYPE (argtype)); + else + return error_mark_node; + } /* If fn was found by a using declaration, the conversion path will be to the derived class, not the base declaring fn. We must convert from derived to base. */ Index: cvt.c =================================================================== --- cvt.c (revision 197804) +++ cvt.c (working copy) @@ -40,7 +40,7 @@ static tree cp_convert_to_pointer (tree, tree, tsu static tree convert_to_pointer_force (tree, tree, tsubst_flags_t); static tree build_type_conversion (tree, tree); static tree build_up_reference (tree, tree, int, tree, tsubst_flags_t); -static void warn_ref_binding (location_t, tree, tree, tree); +static void diagnose_ref_binding (location_t, tree, tree, tree); /* Change of width--truncation and extension of integers or reals-- is represented with NOP_EXPR. Proper functioning of many things @@ -371,7 +371,7 @@ build_up_reference (tree type, tree arg, int flags non-volatile const type. */ static void -warn_ref_binding (location_t loc, tree reftype, tree intype, tree decl) +diagnose_ref_binding (location_t loc, tree reftype, tree intype, tree decl) { tree ttl = TREE_TYPE (reftype); @@ -456,9 +456,9 @@ convert_to_reference (tree reftype, tree expr, int tree ttl = TREE_TYPE (reftype); tree ttr = lvalue_type (expr); - if ((complain & tf_warning) + if ((complain & tf_error) && ! real_lvalue_p (expr)) - warn_ref_binding (loc, reftype, intype, decl); + diagnose_ref_binding (loc, reftype, intype, decl); if (! (convtype & CONV_CONST) && !at_least_as_qualified_p (ttl, ttr)) @@ -502,8 +502,8 @@ convert_to_reference (tree reftype, tree expr, int ICR_CONVERTING, 0, 0, complain); if (rval == NULL_TREE || rval == error_mark_node) return rval; - if (complain & tf_warning) - warn_ref_binding (loc, reftype, intype, decl); + if (complain & tf_error) + diagnose_ref_binding (loc, reftype, intype, decl); rval = build_up_reference (reftype, rval, flags, decl, complain); } Index: typeck.c =================================================================== --- typeck.c (revision 197804) +++ typeck.c (working copy) @@ -54,7 +54,7 @@ static tree get_delta_difference (tree, tree, bool static void casts_away_constness_r (tree *, tree *, tsubst_flags_t); static bool casts_away_constness (tree, tree, tsubst_flags_t); static void maybe_warn_about_returning_address_of_local (tree); -static tree lookup_destructor (tree, tree, tree); +static tree lookup_destructor (tree, tree, tree, tsubst_flags_t); static void warn_args_num (location_t, tree, bool); static int convert_arguments (tree, vec **, tree, int, tsubst_flags_t); @@ -2469,7 +2469,8 @@ build_class_member_access_expr (tree object, tree SCOPE is NULL, by OBJECT.DTOR_NAME, where DTOR_NAME is ~type. */ static tree -lookup_destructor (tree object, tree scope, tree dtor_name) +lookup_destructor (tree object, tree scope, tree dtor_name, + tsubst_flags_t complain) { tree object_type = TREE_TYPE (object); tree dtor_type = TREE_OPERAND (dtor_name, 0); @@ -2477,8 +2478,9 @@ static tree if (scope && !check_dtor_name (scope, dtor_type)) { - error ("qualified type %qT does not match destructor name ~%qT", - scope, dtor_type); + if (complain & tf_error) + error ("qualified type %qT does not match destructor name ~%qT", + scope, dtor_type); return error_mark_node; } if (identifier_p (dtor_type)) @@ -2489,16 +2491,18 @@ static tree dtor_type = object_type; else { - error ("object type %qT does not match destructor name ~%qT", - object_type, dtor_type); + if (complain & tf_error) + error ("object type %qT does not match destructor name ~%qT", + object_type, dtor_type); return error_mark_node; } } else if (!DERIVED_FROM_P (dtor_type, TYPE_MAIN_VARIANT (object_type))) { - error ("the type being destroyed is %qT, but the destructor refers to %qT", - TYPE_MAIN_VARIANT (object_type), dtor_type); + if (complain & tf_error) + error ("the type being destroyed is %qT, but the destructor " + "refers to %qT", TYPE_MAIN_VARIANT (object_type), dtor_type); return error_mark_node; } expr = lookup_member (dtor_type, complete_dtor_identifier, @@ -2731,7 +2735,7 @@ finish_class_member_access_expr (tree object, tree } if (TREE_CODE (name) == BIT_NOT_EXPR) - member = lookup_destructor (object, scope, name); + member = lookup_destructor (object, scope, name, complain); else { /* Look up the member. */ @@ -3933,7 +3937,8 @@ cp_build_binary_op (location_t location, if ((invalid_op_diag = targetm.invalid_binary_op (code, type0, type1))) { - error (invalid_op_diag); + if (complain & tf_error) + error (invalid_op_diag); return error_mark_node; } @@ -4600,7 +4605,8 @@ cp_build_binary_op (location_t location, || !same_scalar_type_ignoring_signedness (TREE_TYPE (type0), TREE_TYPE (type1))) { - binary_op_error (location, code, type0, type1); + if (complain & tf_error) + binary_op_error (location, code, type0, type1); return error_mark_node; } arithmetic_types_p = 1; @@ -4612,11 +4618,12 @@ cp_build_binary_op (location_t location, && (shorten || common || short_compare)) { result_type = cp_common_type (type0, type1); - do_warn_double_promotion (result_type, type0, type1, - "implicit conversion from %qT to %qT " - "to match other operand of binary " - "expression", - location); + if (complain & tf_warning) + do_warn_double_promotion (result_type, type0, type1, + "implicit conversion from %qT to %qT " + "to match other operand of binary " + "expression", + location); } if (!result_type) @@ -4954,10 +4961,11 @@ build_x_unary_op (location_t loc, enum tree_code c tree fn = get_first_fn (xarg); if (DECL_CONSTRUCTOR_P (fn) || DECL_DESTRUCTOR_P (fn)) { - error (DECL_CONSTRUCTOR_P (fn) - ? G_("taking address of constructor %qE") - : G_("taking address of destructor %qE"), - xarg); + if (complain & tf_error) + error (DECL_CONSTRUCTOR_P (fn) + ? G_("taking address of constructor %qE") + : G_("taking address of destructor %qE"), + xarg); return error_mark_node; } } @@ -4970,17 +4978,23 @@ build_x_unary_op (location_t loc, enum tree_code c if (TREE_CODE (xarg) != OFFSET_REF || !TYPE_P (TREE_OPERAND (xarg, 0))) { - error ("invalid use of %qE to form a pointer-to-member-function", - xarg); - if (TREE_CODE (xarg) != OFFSET_REF) - inform (input_location, " a qualified-id is required"); + if (complain & tf_error) + { + error ("invalid use of %qE to form a " + "pointer-to-member-function", xarg); + if (TREE_CODE (xarg) != OFFSET_REF) + inform (input_location, " a qualified-id is required"); + } return error_mark_node; } else { - error ("parentheses around %qE cannot be used to form a" - " pointer-to-member-function", - xarg); + if (complain & tf_error) + error ("parentheses around %qE cannot be used to form a" + " pointer-to-member-function", + xarg); + else + return error_mark_node; PTRMEM_OK_P (xarg) = 1; } } @@ -5395,7 +5409,8 @@ cp_build_unary_op (enum tree_code code, tree xarg, : code), TREE_TYPE (xarg)))) { - error (invalid_op_diag); + if (complain & tf_error) + error (invalid_op_diag); return error_mark_node; } @@ -6028,7 +6043,8 @@ cp_build_compound_expr (tree lhs, tree rhs, tsubst if (type_unknown_p (rhs)) { - error ("no context to resolve type of %qE", rhs); + if (complain & tf_error) + error ("no context to resolve type of %qE", rhs); return error_mark_node; } @@ -7577,8 +7593,13 @@ build_ptrmemfunc (tree type, tree pfn, int force, if (!force && !can_convert_arg (to_type, TREE_TYPE (pfn), pfn, LOOKUP_NORMAL, complain)) - error ("invalid conversion to type %qT from type %qT", - to_type, pfn_type); + { + if (complain & tf_error) + error ("invalid conversion to type %qT from type %qT", + to_type, pfn_type); + else + return error_mark_node; + } n = get_delta_difference (TYPE_PTRMEMFUNC_OBJECT_TYPE (pfn_type), TYPE_PTRMEMFUNC_OBJECT_TYPE (to_type),