From patchwork Wed Jul 25 14:04:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franz Sirl X-Patchwork-Id: 949208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-482343-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lauterbach.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="eaVBJ62A"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41bH6z574bz9s1x for ; Thu, 26 Jul 2018 00:05:14 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=MJK1kN2Qkn81tA3sGx03WW9KdQi6Wk18rvPwQJSaShKuQkycjB pd3cPUvtu0F3+UUAqHqOg2yq20dPG1dsVC2qodNgJNoQtgS5n7Yfuqnk92qniOSz C9uL53a11DisZx6O6WdDw5ZFiwbF9qbxAmY1swCgQYXeywBms9k8swtOA= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=bbATxMYM2pElXTrCiMr7iA+8qhU=; b=eaVBJ62A0Nscyr2jafQr vHcMYFgHAeTzuJUajrURgF9SXKS65mGgjdQW3EnzPmDs6XJwPJl0V88rQ8lrFKyD KvVc9NHO+p7KdV0vxG8+NnKho3JnXSJk2zwVI5Q00XV+EtpLzZlotHCB6D6q86sk z2vDY/DV8E4Hrv0FpQJz/EY= Received: (qmail 58894 invoked by alias); 25 Jul 2018 14:05:06 -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 58884 invoked by uid 89); 25 Jul 2018 14:05:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:envelope-sender X-HELO: smtp1.lauterbach.com Received: from smtp1.lauterbach.com (HELO smtp1.lauterbach.com) (62.154.241.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Jul 2018 14:05:03 +0000 Received: (qmail 1363 invoked by uid 484); 25 Jul 2018 14:05:01 -0000 X-Qmail-Scanner-Diagnostics: from 10.2.11.10 by smtp1.lauterbach.com (envelope-from , uid 484) with qmail-scanner-2.11 (mhr: 1.0. clamdscan: 0.99/21437. spamassassin: 3.4.0. Clear:RC:1(10.2.11.10):. Processed in 0.517081 secs); 25 Jul 2018 14:05:01 -0000 Received: from unknown (HELO [10.2.11.10]) (Authenticated_SSL:fsirl@[10.2.11.10]) (envelope-sender ) by smtp1.lauterbach.com (qmail-ldap-1.03) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 25 Jul 2018 14:04:59 -0000 To: GCC Patches , Martin Sebor From: Franz Sirl Subject: [PATCH] Alias -Warray-bounds to -Warray-bounds=1 Message-ID: Date: Wed, 25 Jul 2018 16:04:59 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, as discussed with Martin, this patch consolidates -Warray-bounds into an alias of -Warray-bounds=1. Bootstrapped on x86_64-linux, no regressions. Please apply if it's OK. Franz. gcc/ChangeLog: 2018-07-25 Franz Sirl * common.opt: Alias -Warray-bounds to -Warray-bounds=1. * builtins.c (c_strlen): Use OPT_Warray_bounds_. * gimple-ssa-warn-restrict.c (maybe_diag_offset_bounds): Likewise. * tree-vrp.c (vrp_prop::check_array_ref, vrp_prop::check_mem_ref, vrp_prop::search_for_addr_array): Likewise. gcc/c-family/ChangeLog: 2018-07-25 Franz Sirl * c.opt: Remove -Warray-bounds. * c-common.c (fold_offsetof, convert_vector_to_array_for_subscript): Use OPT_Warray_bounds_. Index: gcc/builtins.c =================================================================== --- gcc/builtins.c (revision 262966) +++ gcc/builtins.c (working copy) @@ -675,7 +675,7 @@ c_strlen (tree src, int only_value) if (only_value != 2 && !TREE_NO_WARNING (src)) { - warning_at (loc, OPT_Warray_bounds, + warning_at (loc, OPT_Warray_bounds_, "offset %qwi outside bounds of constant string", eltoff); TREE_NO_WARNING (src) = 1; Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c (revision 262966) +++ gcc/c-family/c-common.c (working copy) @@ -6257,7 +6257,7 @@ fold_offsetof (tree expr, tree type, enum tree_cod definition thereof. */ if (TREE_CODE (v) == ARRAY_REF || TREE_CODE (v) == COMPONENT_REF) - warning (OPT_Warray_bounds, + warning (OPT_Warray_bounds_, "index %E denotes an offset " "greater than size of %qT", t, TREE_TYPE (TREE_OPERAND (expr, 0))); @@ -7662,7 +7662,7 @@ convert_vector_to_array_for_subscript (location_t if (TREE_CODE (index) == INTEGER_CST) if (!tree_fits_uhwi_p (index) || maybe_ge (tree_to_uhwi (index), TYPE_VECTOR_SUBPARTS (type))) - warning_at (loc, OPT_Warray_bounds, "index value is out of bound"); + warning_at (loc, OPT_Warray_bounds_, "index value is out of bound"); /* We are building an ARRAY_REF so mark the vector as addressable to not run into the gimplifiers premature setting of DECL_GIMPLE_REG_P Index: gcc/c-family/c.opt =================================================================== --- gcc/c-family/c.opt (revision 262966) +++ gcc/c-family/c.opt (working copy) @@ -326,10 +326,6 @@ Wno-alloca-larger-than C ObjC C++ LTO ObjC++ Alias(Walloca-larger-than=,18446744073709551615EiB,none) Warning -Wno-alloca-larger-than Disable Walloca-larger-than= warning. Equivalent to Walloca-larger-than= or larger. -Warray-bounds -LangEnabledBy(C ObjC C++ LTO ObjC++) -; in common.opt - Warray-bounds= LangEnabledBy(C ObjC C++ LTO ObjC++,Wall,1,0) ; in common.opt Index: gcc/common.opt =================================================================== --- gcc/common.opt (revision 262966) +++ gcc/common.opt (working copy) @@ -539,8 +539,7 @@ Common Var(warn_aggressive_loop_optimizations) Ini Warn if a loop with constant number of iterations triggers undefined behavior. Warray-bounds -Common Var(warn_array_bounds) Warning -Warn if an array is accessed out of bounds. +Common Warning Alias(Warray-bounds=,1,0) Warray-bounds= Common Joined RejectNegative UInteger Var(warn_array_bounds) Warning IntegerRange(0, 2) Index: gcc/gimple-ssa-warn-restrict.c =================================================================== --- gcc/gimple-ssa-warn-restrict.c (revision 262966) +++ gcc/gimple-ssa-warn-restrict.c (working copy) @@ -1619,7 +1619,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c if (DECL_P (ref.base) && TREE_CODE (type = TREE_TYPE (ref.base)) == ARRAY_TYPE) { - if (warning_at (loc, OPT_Warray_bounds, + if (warning_at (loc, OPT_Warray_bounds_, "%G%qD pointer overflow between offset %s " "and size %s accessing array %qD with type %qT", call, func, rangestr[0], rangestr[1], ref.base, type)) @@ -1629,13 +1629,13 @@ maybe_diag_offset_bounds (location_t loc, gcall *c warned = true; } else - warned = warning_at (loc, OPT_Warray_bounds, + warned = warning_at (loc, OPT_Warray_bounds_, "%G%qD pointer overflow between offset %s " "and size %s", call, func, rangestr[0], rangestr[1]); } else - warned = warning_at (loc, OPT_Warray_bounds, + warned = warning_at (loc, OPT_Warray_bounds_, "%G%qD pointer overflow between offset %s " "and size %s", call, func, rangestr[0], rangestr[1]); @@ -1652,7 +1652,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c if (DECL_P (ref.base)) { if ((ref.basesize < maxobjsize - && warning_at (loc, OPT_Warray_bounds, + && warning_at (loc, OPT_Warray_bounds_, form ? G_("%G%qD forming offset %s is out of " "the bounds [0, %wu] of object %qD with " @@ -1661,7 +1661,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c "[0, %wu] of object %qD with type %qT"), call, func, rangestr[0], ref.basesize.to_uhwi (), ref.base, TREE_TYPE (ref.base))) - || warning_at (loc, OPT_Warray_bounds, + || warning_at (loc, OPT_Warray_bounds_, form ? G_("%G%qD forming offset %s is out of " "the bounds of object %qD with type %qT") @@ -1676,7 +1676,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c } } else if (ref.basesize < maxobjsize) - warned = warning_at (loc, OPT_Warray_bounds, + warned = warning_at (loc, OPT_Warray_bounds_, form ? G_("%G%qD forming offset %s is out " "of the bounds [0, %wu]") @@ -1684,7 +1684,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c "of the bounds [0, %wu]"), call, func, rangestr[0], ref.basesize.to_uhwi ()); else - warned = warning_at (loc, OPT_Warray_bounds, + warned = warning_at (loc, OPT_Warray_bounds_, form ? G_("%G%qD forming offset %s is out of bounds") : G_("%G%qD offset %s is out of bounds"), @@ -1697,7 +1697,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c type = TREE_TYPE (type); type = TYPE_MAIN_VARIANT (type); - warned = warning_at (loc, OPT_Warray_bounds, + warned = warning_at (loc, OPT_Warray_bounds_, "%G%qD offset %s from the object at %qE is out " "of the bounds of %qT", call, func, rangestr[0], ref.base, type); @@ -1706,7 +1706,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c { tree type = TYPE_MAIN_VARIANT (TREE_TYPE (ref.ref)); - warned = warning_at (loc, OPT_Warray_bounds, + warned = warning_at (loc, OPT_Warray_bounds_, "%G%qD offset %s from the object at %qE is out " "of the bounds of referenced subobject %qD with " "type %qT at offset %wu", Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c (revision 262966) +++ gcc/tree-vrp.c (working copy) @@ -4841,7 +4841,7 @@ vrp_prop::check_array_ref (location_t location, tr /* Empty array. */ if (up_bound && tree_int_cst_equal (low_bound, up_bound_p1)) { - warning_at (location, OPT_Warray_bounds, + warning_at (location, OPT_Warray_bounds_, "array subscript %E is above array bounds of %qT", low_bound, artype); TREE_NO_WARNING (ref) = 1; @@ -4867,7 +4867,7 @@ vrp_prop::check_array_ref (location_t location, tr && TREE_CODE (low_sub) == INTEGER_CST && tree_int_cst_le (low_sub, low_bound)) { - warning_at (location, OPT_Warray_bounds, + warning_at (location, OPT_Warray_bounds_, "array subscript [%E, %E] is outside array bounds of %qT", low_sub, up_sub, artype); TREE_NO_WARNING (ref) = 1; @@ -4885,7 +4885,7 @@ vrp_prop::check_array_ref (location_t location, tr dump_generic_expr (MSG_NOTE, TDF_SLIM, ref); fprintf (dump_file, "\n"); } - warning_at (location, OPT_Warray_bounds, + warning_at (location, OPT_Warray_bounds_, "array subscript %E is above array bounds of %qT", up_sub, artype); TREE_NO_WARNING (ref) = 1; @@ -4899,7 +4899,7 @@ vrp_prop::check_array_ref (location_t location, tr dump_generic_expr (MSG_NOTE, TDF_SLIM, ref); fprintf (dump_file, "\n"); } - warning_at (location, OPT_Warray_bounds, + warning_at (location, OPT_Warray_bounds_, "array subscript %E is below array bounds of %qT", low_sub, artype); TREE_NO_WARNING (ref) = 1; @@ -5135,12 +5135,12 @@ vrp_prop::check_mem_ref (location_t location, tree } if (offrange[0] == offrange[1]) - warning_at (location, OPT_Warray_bounds, + warning_at (location, OPT_Warray_bounds_, "array subscript %wi is outside array bounds " "of %qT", offrange[0].to_shwi (), reftype); else - warning_at (location, OPT_Warray_bounds, + warning_at (location, OPT_Warray_bounds_, "array subscript [%wi, %wi] is outside array bounds " "of %qT", offrange[0].to_shwi (), offrange[1].to_shwi (), reftype); @@ -5157,7 +5157,7 @@ vrp_prop::check_mem_ref (location_t location, tree { HOST_WIDE_INT tmpidx = extrema[i].to_shwi () / eltsize.to_shwi (); - warning_at (location, OPT_Warray_bounds, + warning_at (location, OPT_Warray_bounds_, "intermediate array offset %wi is outside array bounds " "of %qT", tmpidx, reftype); @@ -5218,7 +5218,7 @@ vrp_prop::search_for_addr_array (tree t, location_ dump_generic_expr (MSG_NOTE, TDF_SLIM, t); fprintf (dump_file, "\n"); } - warning_at (location, OPT_Warray_bounds, + warning_at (location, OPT_Warray_bounds_, "array subscript %wi is below array bounds of %qT", idx.to_shwi (), TREE_TYPE (tem)); TREE_NO_WARNING (t) = 1; @@ -5232,7 +5232,7 @@ vrp_prop::search_for_addr_array (tree t, location_ dump_generic_expr (MSG_NOTE, TDF_SLIM, t); fprintf (dump_file, "\n"); } - warning_at (location, OPT_Warray_bounds, + warning_at (location, OPT_Warray_bounds_, "array subscript %wu is above array bounds of %qT", idx.to_uhwi (), TREE_TYPE (tem)); TREE_NO_WARNING (t) = 1;