From patchwork Tue Jan 10 22:16:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 90769 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp835234qgi; Tue, 10 Jan 2017 14:16:24 -0800 (PST) X-Received: by 10.84.236.2 with SMTP id q2mr8148214plk.148.1484086584186; Tue, 10 Jan 2017 14:16:24 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id m188si3478430pfc.211.2017.01.10.14.16.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2017 14:16:24 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-445804-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-445804-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-445804-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=vMKmm5adX9MgQrsCgPYfIn7PtZvlL1ktVXPRoNGPjstSgHE6ob AwtKQJyCW/YrLWTtMipZOPITv6mFQbpjIPRX1SCRcMRi1+kBvQw+cC0nctdmGHWW STL7ecuK3hKrTwzHFqmkwVjIC/AdYQjKCV4PgmNyko6IvP4PQUTNJFq2s= 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=SXfPpsq5u0UcExkSArAsEVXMHwo=; b=XuglkCzV2hBggX2KtKff o/JujO4BDRHlylah3F1QY82Pn2QiafWAEAzVYniae6lmDa2Tb+nkcBxEHEchzype qWtis71y5+o2pc5NMwpmuACw65J1igZ57jXGyXjSNcp6wcW+9i1CVmLNgdSTTIfM cL29f2Zd5YUbay0pySQA83E= Received: (qmail 16765 invoked by alias); 10 Jan 2017 22:16:10 -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 16749 invoked by uid 89); 10 Jan 2017 22:16:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=521, 7, 5217, implying, 32s X-HELO: mail-qk0-f180.google.com Received: from mail-qk0-f180.google.com (HELO mail-qk0-f180.google.com) (209.85.220.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Jan 2017 22:16:08 +0000 Received: by mail-qk0-f180.google.com with SMTP id u25so574205532qki.2 for ; Tue, 10 Jan 2017 14:16:08 -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=mtj2GdEvKDQNWuDHhYRKdOxMNKrysRSO1w9Dcx9RBMU=; b=DamyEFmpUnn/2tO5RhIMtXUDwOKVGYFUu6xmTmbEvceCuWsDAZhv4me/Us8W9sp1a6 cNKesu8ZDGvfwLLtE/WAqhc4Ar2+Z9kyNydwN1x35tukuqHnPeZZJKjUJUjahCvNUWLw 6mYpWar2MyKv7/WSRvBAOhXvjiR1eByZ+F7b3wc7/uv/1ECcAzPKxgG3inig8qPt0Xal 5DSbXrnYtFy4x/HJtEB/4PT6RfWez4hV8S8xCzudDJjEKqxQF/+rH8hLndwH+jvxGEhY kkefxXa1/W1JmFRtQztOXBjL4xxZyDiiybFwrenfVeWbKdNktt7chAU9jNcrDxt2czsx YGDg== X-Gm-Message-State: AIkVDXKuy3DxFZBI441sk/vaRO031cbcJQLUSFKtjU0kb+36dhMYE3SuFULlr398clvnmA== X-Received: by 10.55.44.193 with SMTP id s184mr5591842qkh.278.1484086567131; Tue, 10 Jan 2017 14:16:07 -0800 (PST) Received: from [192.168.0.26] (97-122-90-209.hlrn.qwest.net. [97.122.90.209]) by smtp.gmail.com with ESMTPSA id i1sm2369974qte.32.2017.01.10.14.16.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2017 14:16:06 -0800 (PST) To: Gcc Patch List , Richard Biener From: Martin Sebor Subject: [PATCH] adding missing LTO to some warning options (PR 78606) Message-ID: <06c24069-90af-5778-52a2-c9167eb109ab@gmail.com> Date: Tue, 10 Jan 2017 15:16:03 -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 The -Walloca-larger-than, -Wformat-length, and -Wformat-truncation options do not mention LTO among the supported languages and so are disabled when -flto is used, causing false negatives. The attached patch adds the missing LTO to the three options. This makes -Walloca-larger-than work with LTO but not the other two options, implying that something else is preventing the gimple-ssa- sprintf pass from running when -flto is enabled. I haven't had the cycles to look into what that might be yet. Since the root causes are independent I'd like to commit this patch first and deal with the -Wformat-{length,truncation} problem separately, under a new bug (or give someone with a better understanding of LTO the opportunity to do it). Thanks Martin PR c/78768 - -Walloca-larger-than and -Wformat-length warnings disabled by -flto gcc/c-family/ChangeLog: PR c/78768 * c.opt (-Walloca-larger-than, -Wformat-length, -Wformat-truncation): Also enable for LTO. gcc/testsuite/ChangeLog: PR c/78768 * gcc.dg/pr78768.c: New test. Index: gcc/c-family/c.opt =================================================================== --- gcc/c-family/c.opt (revision 244294) +++ gcc/c-family/c.opt (working copy) @@ -313,7 +313,7 @@ C ObjC C++ ObjC++ Var(warn_alloc_zero) Warning -Walloc-zero Warn for calls to allocation functions that specify zero bytes. Walloca-larger-than= -C ObjC C++ ObjC++ Var(warn_alloca_limit) Warning Joined RejectNegative UInteger +C ObjC C++ LTO ObjC++ Var(warn_alloca_limit) Warning Joined RejectNegative UInteger -Walloca-larger-than= Warn on unbounded uses of alloca, and on bounded uses of alloca whose bound can be larger than bytes. @@ -521,7 +521,7 @@ C ObjC C++ ObjC++ Var(warn_format_extra_args) Warn Warn if passing too many arguments to a function for its format string. Wformat-length -C ObjC C++ ObjC++ Warning Alias(Wformat-length=, 1, 0) +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. @@ -538,7 +538,7 @@ C ObjC C++ ObjC++ Var(warn_format_signedness) Warn Warn about sign differences with format functions. Wformat-truncation -C ObjC C++ ObjC++ Warning Alias(Wformat-truncation=, 1, 0) +C ObjC C++ LTO ObjC++ Warning Alias(Wformat-truncation=, 1, 0) Warn about calls to snprintf and similar functions that truncate output. Same as -Wformat-truncation=1. Index: gcc/testsuite/gcc.dg/pr78768.c =================================================================== --- gcc/testsuite/gcc.dg/pr78768.c (revision 0) +++ gcc/testsuite/gcc.dg/pr78768.c (working copy) @@ -0,0 +1,13 @@ +/* PR c/78768 - -Walloca-larger-than and -Wformat-length warnings disabled + by -flto + { dg-do run } + { dg-options "-O2 -Walloca-larger-than=10 -Wformat -Wformat-length -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 *-*-* } } */ + + return 0; +}