From patchwork Thu Jan 12 20:31:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 91231 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1809487qgi; Thu, 12 Jan 2017 12:32:10 -0800 (PST) X-Received: by 10.99.19.65 with SMTP id 1mr19679202pgt.153.1484253130920; Thu, 12 Jan 2017 12:32:10 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v32si10276706plb.284.2017.01.12.12.32.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jan 2017 12:32:10 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-446000-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-446000-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-446000-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com 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=r+rtUkg00/FDIbW8JbontuCRCOn7E0e4FoZ9AZxEzCL3O+RDnl tGtzucDHltWIHz7mxxxJxmA7UGgWnV9mpQcxbJzfEdgQU0EqfuDswkrAMDZv+gDe THTUrtJeBgYveK/mSmFW8t98pVWccelulqVAdx8lbVzK8aHyfwhU/DwII= 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=7/iFyqsEUFV7BFVyvs0riMXajpo=; b=GpO7jvR6q+tGzRV5M/QN zLzjfe7tV1dlERvpd9V4r8eYXi5j6HINGwgeJUFl207YqxLdtNEBDHUS6Bsto0nC Lhv1YoS7DmrlSF5hBPGc/pI2Veb+7n/joia0lWyGhMf1W1a0CT3CQa1VXDum7Cdu IQmBemdd6Knxem9/cImCBVQ= Received: (qmail 69227 invoked by alias); 12 Jan 2017 20:31:58 -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 69207 invoked by uid 89); 12 Jan 2017 20:31:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=longest, 23467, gate, anomalies X-HELO: mail-qk0-f170.google.com Received: from mail-qk0-f170.google.com (HELO mail-qk0-f170.google.com) (209.85.220.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Jan 2017 20:31:54 +0000 Received: by mail-qk0-f170.google.com with SMTP id s140so33632842qke.0 for ; Thu, 12 Jan 2017 12:31:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=djj+q17jKUKdMlyaabJcm+mmLk2wKGrBjFyw6QMh5Pc=; b=K918zDZQHI3JgaasIAQqOGqbTVnlP3tm3S4ur9qy6IOnOjlkwg4cFHKRYVQyhXdl1Z FqicO8Csoapke2JAMSFlOjxodEJogkIFN7fEyAMfNzqvXoVjV+m2Er4/DtJNnki6k2FX SOxNABC1ja5fi78OTfqtSV3M4HfZZKIUhFdIUDp7pfq/9LQKuzyVwe18+wrLleJlo5T+ dh9uA+brx8BNME5QaVRr/hx5atTx2GymsoGM+MSarjWq3dKHFpeggC/ijrIYvGZEgwgL v3Ye7Mahr/DpUFuX2Ou+pfgu/GjXMB/XMksOKDGXJNxC5LedR31RG8wr7StftvXrar+4 xzvw== X-Gm-Message-State: AIkVDXKlj1D0Rb2CBsA9myUxUr6cWtBu2Yd4g51SYx0FR/xonul0Vg1NIzm8WfH1t2b3PA== X-Received: by 10.55.47.4 with SMTP id v4mr15113272qkh.77.1484253112412; Thu, 12 Jan 2017 12:31:52 -0800 (PST) Received: from [192.168.0.26] (71-212-227-187.hlrn.qwest.net. [71.212.227.187]) by smtp.gmail.com with ESMTPSA id b12sm7485180qta.27.2017.01.12.12.31.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jan 2017 12:31:51 -0800 (PST) To: Gcc Patch List From: Martin Sebor Subject: [PATCH] rename -Wformat-length to -Wformat-overflow Message-ID: Date: Thu, 12 Jan 2017 13:31:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 X-IsSubscribed: yes With the move of the snprintf truncation checking from -Wformat-length to the dedicated -Wformat-truncation option (done in r244210), -Wformat-length isn't as descriptive as it could and should be for an option whose sole focus is the detection of sprintf buffer overflow. The name is also inconsistent with the name of -Wstringop-overflow option which focuses on detecting buffer overflow by string operations such as strcpy or memcpy. To make the purpose of the option clearer and its name consistent with -Wstringop-overflow the attached patch renames -Wformat-length to -Wformat-overflow. Thanks Martin gcc/c-family/ChangeLog: * c.opt (-Wformat-length): Rename... (-Wformat-overflow): ...to this. gcc/ChangeLog: * doc/invoke.texi (Warning Options): Rename -Wformat-length to -Wformat-overflow. * gimple-ssa-sprintf.c (pass_sprintf_length::gate): Adjust. (min_bytes_remaining): Same. (get_string_length): Same. (format_string): Same. (format_directive): Same. (add_bytes): Same. (pass_sprintf_length::handle_gimple_call): Same. gcc/testsuite/ChangeLog: * gcc.c-torture/execute/pr78622.c: Adjust. * gcc.dg/pr78138.c: Adjust. * gcc.dg/pr78768.c: Adjust. * gcc.dg/tree-ssa/builtin-sprintf-4.c: Adjust. * gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Adjust. * gcc.dg/tree-ssa/builtin-sprintf-warn-2.c: Adjust. * gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: Adjust. * gcc.dg/tree-ssa/builtin-sprintf-warn-4.c: Adjust. * gcc.dg/tree-ssa/builtin-sprintf-warn-6.c: Adjust. * gcc.dg/tree-ssa/builtin-sprintf-warn-7.c: Adjust. * gcc.dg/tree-ssa/builtin-sprintf-warn-8.c: Adjust. * gcc.dg/tree-ssa/builtin-sprintf-warn-9.c: Adjust. * gcc.dg/tree-ssa/pr78605.c: Adjust. * gcc.dg/tree-ssa/pr78622.c: Adjust. Index: gcc/c-family/c.opt =================================================================== --- gcc/c-family/c.opt (revision 244382) +++ gcc/c-family/c.opt (working copy) @@ -520,15 +520,15 @@ Wformat-extra-args C ObjC C++ ObjC++ Var(warn_format_extra_args) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 1, 0) Warn if passing too many arguments to a function for its format string. -Wformat-length -C ObjC C++ LTO ObjC++ Warning Alias(Wformat-length=, 1, 0) -Warn about function calls with format strings that write past the end -of the destination region. Same as -Wformat-length=1. - Wformat-nonliteral C ObjC C++ ObjC++ Var(warn_format_nonliteral) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0) Warn about format strings that are not literals. +Wformat-overflow +C ObjC C++ LTO ObjC++ Warning Alias(Wformat-overflow=, 1, 0) +Warn about function calls with format strings that write past the end +of the destination region. Same as -Wformat-overflow=1. + Wformat-security C ObjC C++ ObjC++ Var(warn_format_security) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0) Warn about possible security problems with format functions. @@ -554,8 +554,8 @@ Wformat= C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) Warn about printf/scanf/strftime/strfmon format string anomalies. -Wformat-length= -C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format_length) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 1, 0) +Wformat-overflow= +C ObjC C++ LTO ObjC++ Joined RejectNegative UInteger Var(warn_format_overflow) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 1, 0) Warn about function calls with format strings that write past the end of the destination region. Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi (revision 244382) +++ gcc/doc/invoke.texi (working copy) @@ -274,8 +274,8 @@ Objective-C and Objective-C++ Dialects}. -Wno-div-by-zero -Wdouble-promotion -Wduplicated-cond @gol -Wempty-body -Wenum-compare -Wno-endif-labels -Wexpansion-to-defined @gol -Werror -Werror=* -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol --Wno-format-contains-nul -Wno-format-extra-args -Wformat-length=@var{n} @gol --Wformat-nonliteral @gol +-Wno-format-contains-nul -Wno-format-extra-args @gol +-Wformat-nonliteral -Wformat-overflow=@var{n} @gol -Wformat-security -Wformat-signedness -Wformat-truncation=@var{n} @gol -Wformat-y2k -Wframe-address @gol -Wframe-larger-than=@var{len} -Wno-free-nonheap-object -Wjump-misses-init @gol @@ -3957,10 +3957,10 @@ in the case of @code{scanf} formats, this option s warning if the unused arguments are all pointers, since the Single Unix Specification says that such unused arguments are allowed. -@item -Wformat-length -@itemx -Wformat-length=@var{level} -@opindex Wformat-length -@opindex Wno-format-length +@item -Wformat-overflow +@itemx -Wformat-overflow=@var{level} +@opindex Wformat-overflow +@opindex Wno-format-overflow Warn about calls to formatted input/output functions such as @code{sprintf} and @code{vsprintf} that might overflow the destination buffer. When the exact number of bytes written by a format directive cannot be determined @@ -3970,11 +3970,11 @@ will in most cases improve the accuracy of the war result in false positives. @table @gcctabopt -@item -Wformat-length -@item -Wformat-length=1 -@opindex Wformat-length -@opindex Wno-format-length -Level @var{1} of @option{-Wformat-length} enabled by @option{-Wformat} +@item -Wformat-overflow +@item -Wformat-overflow=1 +@opindex Wformat-overflow +@opindex Wno-format-overflow +Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat} employs a conservative approach that warns only about calls that most likely overflow the buffer. At this level, numeric arguments to format directives with unknown values are assumed to have the value of one, and @@ -3997,7 +3997,7 @@ void f (int a, int b) @} @end smallexample -@item -Wformat-length=2 +@item -Wformat-overflow=2 Level @var{2} warns also about calls that might overflow the destination buffer given an argument of sufficient length or magnitude. At level @var{2}, unknown numeric arguments are assumed to have the minimum @@ -4086,13 +4086,13 @@ compile-time it is estimated based on heuristics t the @var{level} argument and on optimization. While enabling optimization will in most cases improve the accuracy of the warning, it may also result in false positives. Except as noted otherwise, the option uses the same -logic @option{-Wformat-length}. +logic @option{-Wformat-overflow}. @table @gcctabopt @item -Wformat-truncation @item -Wformat-truncation=1 @opindex Wformat-truncation -@opindex Wno-format-length +@opindex Wno-format-overflow Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat} employs a conservative approach that warns only about calls to bounded functions whose return value is unused and that will most likely result @@ -8458,7 +8458,7 @@ if (snprintf (buf, "%08x", i) >= sizeof buf) The @option{-fprintf-return-value} option relies on other optimizations and yields best results with @option{-O2}. It works in tandem with the -@option{-Wformat-length} and @option{-Wformat-truncation} options. +@option{-Wformat-overflow} and @option{-Wformat-truncation} options. The @option{-fprintf-return-value} option is enabled by default. @item -fno-peephole Index: gcc/gimple-ssa-sprintf.c =================================================================== --- gcc/gimple-ssa-sprintf.c (revision 244382) +++ gcc/gimple-ssa-sprintf.c (working copy) @@ -141,7 +141,7 @@ pass_sprintf_length::gate (function *) not optimizing and the pass is being invoked early, or when optimizing and the pass is being invoked during optimization (i.e., "late"). */ - return ((warn_format_length > 0 || flag_printf_return_value) + return ((warn_format_overflow > 0 || flag_printf_return_value) && (optimize > 0) == fold_return_value); } @@ -651,7 +651,7 @@ min_bytes_remaining (unsigned HOST_WIDE_INT navail if (HOST_WIDE_INT_MAX <= navail) return navail; - if (1 < warn_format_length || res.knownrange) + if (1 < warn_format_overflow || res.knownrange) { /* At level 2, or when all directives output an exact number of bytes or when their arguments were bounded by known @@ -728,7 +728,7 @@ struct pass_sprintf_length::call_info /* Return the warning option corresponding to the called function. */ int warnopt () const { - return bounded ? OPT_Wformat_truncation_ : OPT_Wformat_length_; + return bounded ? OPT_Wformat_truncation_ : OPT_Wformat_overflow_; } }; @@ -1653,7 +1653,7 @@ get_string_length (tree str) fmtresult res; res.range.min = (tree_fits_uhwi_p (lenrange[0]) - ? tree_to_uhwi (lenrange[0]) : 1 < warn_format_length); + ? tree_to_uhwi (lenrange[0]) : 1 < warn_format_overflow); res.range.max = (tree_fits_uhwi_p (lenrange[1]) ? tree_to_uhwi (lenrange[1]) : HOST_WIDE_INT_M1U); @@ -1693,12 +1693,12 @@ format_string (const conversion_spec &spec, tree a to a "%lc" directive adjusted for precision but not field width. 6 is the longest UTF-8 sequence for a single wide character. */ const unsigned HOST_WIDE_INT max_bytes_for_unknown_wc - = (0 <= prec ? prec : 1 < warn_format_length ? 6 : 1); + = (0 <= prec ? prec : 1 < warn_format_overflow ? 6 : 1); /* The maximum number of bytes for an unknown string argument to either a "%s" or "%ls" directive adjusted for precision but not field width. */ const unsigned HOST_WIDE_INT max_bytes_for_unknown_str - = (0 <= prec ? prec : 1 < warn_format_length); + = (0 <= prec ? prec : 1 < warn_format_overflow); /* The result is bounded unless overriddden for a non-constant string of an unknown length. */ @@ -1718,7 +1718,7 @@ format_string (const conversion_spec &spec, tree a is the smaller of either 0 (at level 1) or 1 (at level 2) and WIDTH, and the maximum is MB_CUR_MAX in the selected locale, which is unfortunately, unknown. */ - res.range.min = 1 == warn_format_length ? !nul : nul < 1; + res.range.min = 1 == warn_format_overflow ? !nul : nul < 1; res.range.max = max_bytes_for_unknown_wc; /* The range above is good enough to issue warnings but not for value range propagation, so clear BOUNDED. */ @@ -1756,7 +1756,7 @@ format_string (const conversion_spec &spec, tree a { bounded = false; - if (warn_format_length > 1) + if (warn_format_overflow > 1) { /* Leave the minimum number of bytes the wide string converts to equal to its length and set the maximum @@ -2038,7 +2038,7 @@ format_directive (const pass_sprintf_length::call_ || warn_format_trunc > 1)) || (!info.bounded && (spec.specifier == 's' - || 1 < warn_format_length)))) + || 1 < warn_format_overflow)))) { /* The maximum directive output is longer than there is room in the destination and the output length is either @@ -2114,7 +2114,7 @@ format_directive (const pass_sprintf_length::call_ if (!minunder4k || fmtres.range.max > 4095) res->under4k = false; - if (!warned && 1 < warn_format_length + if (!warned && 1 < warn_format_overflow && (!minunder4k || fmtres.range.max > 4095)) { /* The directive output may be longer than the maximum required @@ -2151,7 +2151,7 @@ format_directive (const pass_sprintf_length::call_ if (!warned && (exceedmin - || (1 < warn_format_length + || (1 < warn_format_overflow && res->number_chars_max > target_int_max ()))) { /* The directive output causes the total length of output @@ -2229,7 +2229,7 @@ add_bytes (const pass_sprintf_length::call_info &i are bounded by the arrays they are known to refer to. */ if (!res->warned && (avail_range.max < nbytes - || ((res->knownrange || 1 < warn_format_length) + || ((res->knownrange || 1 < warn_format_overflow) && avail_range.min < nbytes))) { /* Set NAVAIL to the number of available bytes used to decide @@ -2237,7 +2237,7 @@ add_bytes (const pass_sprintf_length::call_info &i warning will depend on AVAIL_RANGE. */ unsigned HOST_WIDE_INT navail = avail_range.max; if (nbytes <= navail && avail_range.min < HOST_WIDE_INT_MAX - && (res->knownrange || 1 < warn_format_length)) + && (res->knownrange || 1 < warn_format_overflow)) navail = avail_range.min; /* Compute the offset of the first format character that is beyond @@ -2346,7 +2346,7 @@ add_bytes (const pass_sprintf_length::call_info &i if (!res->warned && (exceedmin - || (1 < warn_format_length + || (1 < warn_format_overflow && (res->number_chars_max - !end) > target_int_max ()))) { /* The function's output exceeds INT_MAX bytes. */ @@ -2356,7 +2356,7 @@ add_bytes (const pass_sprintf_length::call_info &i warning will depend on AVAIL_RANGE. */ unsigned HOST_WIDE_INT navail = avail_range.max; if (nbytes <= navail && avail_range.min < HOST_WIDE_INT_MAX - && (res->bounded || 1 < warn_format_length)) + && (res->bounded || 1 < warn_format_overflow)) navail = avail_range.min; /* Compute the offset of the first format character that is beyond @@ -3014,7 +3014,7 @@ pass_sprintf_length::handle_gimple_call (gimple_st if (range_type == VR_RANGE) { dstsize - = (warn_format_length < 2 + = (warn_format_overflow < 2 ? wi::fits_uhwi_p (max) ? max.to_uhwi () : max.to_shwi () : wi::fits_uhwi_p (min) ? min.to_uhwi () : min.to_shwi ()); } Index: gcc/testsuite/gcc.c-torture/execute/pr78622.c =================================================================== --- gcc/testsuite/gcc.c-torture/execute/pr78622.c (revision 244382) +++ gcc/testsuite/gcc.c-torture/execute/pr78622.c (working copy) @@ -1,6 +1,6 @@ -/* PR middle-end/78622 - [7 Regression] -Wformat-length/-fprintf-return-value +/* PR middle-end/78622 - [7 Regression] -Wformat-overflow/-fprintf-return-value incorrect with overflow/wrapping - { dg-additional-options "-Wformat-length=2" } */ + { dg-additional-options "-Wformat-overflow=2" } */ __attribute__((noinline, noclone)) int foo (int x) Index: gcc/testsuite/gcc.dg/pr78138.c =================================================================== --- gcc/testsuite/gcc.dg/pr78138.c (revision 244382) +++ gcc/testsuite/gcc.dg/pr78138.c (working copy) @@ -1,7 +1,7 @@ /* PR middle-end/78138 - missing warnings on buffer overflow with non-constant source length { dg-do compile } - { dg-options "-O2 -Wformat-length" } */ + { dg-options "-O2 -Wformat-overflow" } */ char d [5]; Index: gcc/testsuite/gcc.dg/pr78768.c =================================================================== --- gcc/testsuite/gcc.dg/pr78768.c (revision 244382) +++ gcc/testsuite/gcc.dg/pr78768.c (working copy) @@ -1,14 +1,14 @@ -/* PR c/78768 - -Walloca-larger-than and -Wformat-length warnings disabled +/* PR c/78768 - -Walloca-larger-than and -Wformat-overflow warnings disabled by -flto { dg-do run } { dg-require-effective-target lto } - { dg-options "-O2 -Walloca-larger-than=10 -Wformat -Wformat-length -flto" } */ + { dg-options "-O2 -Walloca-larger-than=10 -Wformat -Wformat-overflow -flto" } */ int main (void) { char *d = (char *)__builtin_alloca (12); /* { dg-warning "argument to .alloca. is too large" } */ - __builtin_sprintf (d, "%32s", "x"); /* { dg-warning "directive writing 32 bytes into a region of size 12" "-Wformat-length" { xfail *-*-* } } */ + __builtin_sprintf (d, "%32s", "x"); /* { dg-warning "directive writing 32 bytes into a region of size 12" "-Wformat-overflow" { xfail *-*-* } } */ return 0; } Index: gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-4.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-4.c (revision 244382) +++ gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-4.c (working copy) @@ -1,7 +1,7 @@ /* PR middle-end/78461 - [7 Regression] ICE: in operator+=, at gimple-ssa-sprintf.c:214 Disable warnings to exercise code paths through the pass that may - not be exercised when the -Wformat-length option is in effect. */ + not be exercised when the -Wformat-overflow option is in effect. */ /* { dg-compile } { dg-options "-O2 -fdump-tree-optimized -w" } */ Index: gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c (revision 244382) +++ gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-Wformat -Wformat-length=1 -ftrack-macro-expansion=0" } */ +/* { dg-options "-Wformat -Wformat-overflow=1 -ftrack-macro-expansion=0" } */ /* { dg-require-effective-target int32plus } */ /* When debugging, define LINE to the line number of the test case to exercise @@ -1028,7 +1028,7 @@ void test_sprintf_chk_e_const (void) T (12, "%Le", 9.9999999e+99L);/* { dg-warning "terminating nul" } */ } -/* At -Wformat-length level 1 unknown numbers are assumed to have +/* At -Wformat-overflow level 1 unknown numbers are assumed to have the value one, and unknown strings are assumed to have a zero length. */ Index: gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-2.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-2.c (revision 244382) +++ gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-2.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-std=c99 -Wformat -Wformat-length=2 -ftrack-macro-expansion=0" } */ +/* { dg-options "-std=c99 -Wformat -Wformat-overflow=2 -ftrack-macro-expansion=0" } */ /* When debugging, define LINE to the line number of the test case to exercise and avoid exercising any of the others. The buffer and objsize macros Index: gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-3.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-3.c (revision 244382) +++ gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-3.c (working copy) @@ -4,7 +4,7 @@ -O2 (-ftree-vrp) is necessary for the tests involving ranges to pass, otherwise -O1 is sufficient. { dg-do compile } - { dg-options "-O2 -Wformat -Wformat-length=1 -ftrack-macro-expansion=0" } */ + { dg-options "-O2 -Wformat -Wformat-overflow=1 -ftrack-macro-expansion=0" } */ typedef __SIZE_TYPE__ size_t; Index: gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-4.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-4.c (revision 244382) +++ gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-4.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-Wformat -Wformat-length=1 -fdiagnostics-show-caret" } */ +/* { dg-options "-Wformat -Wformat-overflow=1 -fdiagnostics-show-caret" } */ extern int sprintf (char*, const char*, ...); @@ -17,7 +17,7 @@ void test (void) sprintf (dst + 2, "1", 0); ^~~ { dg-end-multiline-output "" } - { dg-begin-multiline-output "-Wformat-length output" } + { dg-begin-multiline-output "-Wformat-overflow output" } sprintf (dst + 2, "1", 0); ~^ { dg-end-multiline-output "" } @@ -35,7 +35,7 @@ void test (void) sprintf (dst, "1234", 0); ^~~~~~ { dg-end-multiline-output "" } - { dg-begin-multiline-output "-Wformat-length output" } + { dg-begin-multiline-output "-Wformat-overflow output" } sprintf (dst, "1234", 0); ^ { dg-end-multiline-output "" } @@ -54,7 +54,7 @@ void test (void) sprintf (dst, "12345", 0); ^~~~~~~ { dg-end-multiline-output "" } - { dg-begin-multiline-output "-Wformat-length output" } + { dg-begin-multiline-output "-Wformat-overflow output" } sprintf (dst, "12345", 0); ^~ { dg-end-multiline-output "" } @@ -68,7 +68,7 @@ void test (void) sprintf (dst + 2, "%-s", "1"); /* { dg-warning "writing a terminating nul past the end of the destination" "warning" { target *-*-* } .-1 } { dg-message "format output 2 bytes into a destination of size 1" "note" { target *-*-* } .-2 } - { dg-begin-multiline-output "-Wformat-length output" } + { dg-begin-multiline-output "-Wformat-overflow output" } sprintf (dst + 2, "%-s", "1"); ~~~^ { dg-end-multiline-output "" } @@ -80,7 +80,7 @@ void test (void) sprintf (dst + 2, "%-s", "abcd"); /* { dg-warning ".%-s. directive writing 4 bytes into a region of size 1" "warning" { target *-*-* } .-1 } { dg-message "format output 5 bytes into a destination of size 1" "note" { target *-*-* } .-2 } - { dg-begin-multiline-output "-Wformat-length output" } + { dg-begin-multiline-output "-Wformat-overflow output" } sprintf (dst + 2, "%-s", "abcd"); ^~~ ~~~~~~ { dg-end-multiline-output "" } Index: gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-6.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-6.c (revision 244382) +++ gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-6.c (working copy) @@ -1,8 +1,8 @@ -/* PR middle-end/77721 - -Wformat-length not uses arg range for converted vars +/* PR middle-end/77721 - -Wformat-overflow not uses arg range for converted vars Test to verify that the correct range information is made available to the -Wformat-lenght check to prevent warnings. */ /* { dg-do compile } */ -/* { dg-options "-O2 -Wformat -Wformat-length -fdump-tree-optimized" } */ +/* { dg-options "-O2 -Wformat -Wformat-overflow -fdump-tree-optimized" } */ void abort (void); int snprintf (char*, __SIZE_TYPE__, const char*, ...); Index: gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-7.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-7.c (revision 244382) +++ gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-7.c (working copy) @@ -2,7 +2,7 @@ precision { dg-do compile } { dg-require-effective-target int32plus } - { dg-options "-Wformat-length -ftrack-macro-expansion=0" } */ + { dg-options "-Wformat-overflow -ftrack-macro-expansion=0" } */ #define INT_MAX __INT_MAX__ #define INT_MIN (-INT_MAX - 1) Index: gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-8.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-8.c (revision 244382) +++ gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-8.c (working copy) @@ -1,7 +1,7 @@ /* PR middle-end/78519 - missing warning for sprintf %s with null pointer Also exercises null destination pointer and null format string. { dg-do compile } - { dg-options "-O2 -Wformat -Wformat-length -Wno-nonnull -ftrack-macro-expansion=0" } */ + { dg-options "-O2 -Wformat -Wformat-overflow -Wno-nonnull -ftrack-macro-expansion=0" } */ typedef __builtin_va_list va_list; Index: gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-9.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-9.c (revision 244382) +++ gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-9.c (working copy) @@ -2,7 +2,7 @@ Test to verify the correctness of ranges of output computed for floating point directives. { dg-do compile } - { dg-options "-O2 -Wformat -Wformat-length -ftrack-macro-expansion=0" } */ + { dg-options "-O2 -Wformat -Wformat-overflow -ftrack-macro-expansion=0" } */ typedef __builtin_va_list va_list; Index: gcc/testsuite/gcc.dg/tree-ssa/pr78605.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/pr78605.c (revision 244382) +++ gcc/testsuite/gcc.dg/tree-ssa/pr78605.c (working copy) @@ -1,6 +1,6 @@ -/* PR middle-end/78605 - bogus -Wformat-length=1 with %f +/* PR middle-end/78605 - bogus -Wformat-overflow=1 with %f { dg-do compile } - { dg-options "-O2 -Wall -Wextra -Wformat-length=1" } */ + { dg-options "-O2 -Wall -Wextra -Wformat-overflow=1" } */ char d[10]; Index: gcc/testsuite/gcc.dg/tree-ssa/pr78622.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/pr78622.c (revision 244382) +++ gcc/testsuite/gcc.dg/tree-ssa/pr78622.c (working copy) @@ -1,7 +1,7 @@ -/* PR middle-end/78622 - [7 Regression] -Wformat-length/-fprintf-return-value +/* PR middle-end/78622 - [7 Regression] -Wformat-overflow/-fprintf-return-value incorrect with overflow/wrapping { dg-do compile } - { dg-options "-Wformat-length=2" } + { dg-options "-Wformat-overflow=2" } The h and hh length modifiers are a C99 feature (see PR 78959). { dg-require-effective-target c99_runtime } */