From patchwork Mon May 24 22:07:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=UuXfU0q2; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FprtX4t7Qz9sRN for ; Tue, 25 May 2021 08:07:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D89EE3851C1B; Mon, 24 May 2021 22:07:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D89EE3851C1B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621894063; bh=m7y38+9TpVqg6/FkUqHk6gqcamVSLMn7usgZknR/abc=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UuXfU0q2IL22awsakbQeXJlX9fzGCRlbISrvBQ+C4Gq+Z0LlK5W5tdw4w3Nshq3wf ynMd/1FiUp2yO1JFcxwhY5PHVQOQbt+Y8fxN1/E9UXYpqbde+xQGOGEMMQIu28Ltqx EPf4K+4k1+HPntlLznJTzkQTajeHIBwxHQp+8dy0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 4533B3858022 for ; Mon, 24 May 2021 22:07:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4533B3858022 Received: by mail-ot1-x335.google.com with SMTP id h24-20020a9d64180000b029036edcf8f9a6so2380888otl.3 for ; Mon, 24 May 2021 15:07:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=m7y38+9TpVqg6/FkUqHk6gqcamVSLMn7usgZknR/abc=; b=E3QTzt8uWjxZ7Fsivs1oaIDxIYYb2f4yvg9juDvq9My4ieZnGrWKdiP+hjQrG6N/OP aoEgvwkxoDOq7Wk260nK+xUbQUT+/TdEnfc7CAfhp9HFeLmS5rb/TDEn/w8gvtQckuv6 2JLjeOs+ThVzeTpJCByqPIZnLd+Itr23pwqPUuUthHJyxSy+f+0qHj127FMYV7Z7uR9U xOYZG60Ta2826DoFlTfrUxRIIMZlBuHHDjCK5wBiAFgyZBFUUMJpBVoIQnLOqtanVkqg KRVBOfwbACs5m6EJSBozCuG/QbygEFcUkthfIxBQuZ9qf9YwmL8Ig1UAGZ9TJXqD0ZQC mpFA== X-Gm-Message-State: AOAM533xfTNdO4FZH9zX6RHYLmq6WPjlfeJ6UxTC3AYFuR038flbw9TO 4Kjv2cmB2ezGJpYo2x6YYI4= X-Google-Smtp-Source: ABdhPJyqkoyJbU2fpkX4cC3UUqppe5mYwJ7FPfLeRbl0v2dYt9xYAF6PerdRgdsuInpZfUox1zviyw== X-Received: by 2002:a9d:c24:: with SMTP id 33mr19985015otr.289.1621894059744; Mon, 24 May 2021 15:07:39 -0700 (PDT) Received: from [192.168.0.41] (174-16-126-108.hlrn.qwest.net. [174.16.126.108]) by smtp.gmail.com with ESMTPSA id v22sm2849511oic.37.2021.05.24.15.07.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 May 2021 15:07:38 -0700 (PDT) Subject: [PATCH 1/11] introduce xxx_no_warning APIs To: gcc-patches References: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> Message-ID: <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Date: Mon, 24 May 2021 16:07:38 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> Content-Language: en-US X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Cc: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The attached patch introduces the get_no_warning(), set_no_warning(), and copy_no_warning() APIs without making use of them in the rest of GCC. They are in three files: diagnostic-spec.{h,c}: Location-centric overloads. warning-control.cc: Tree- and gimple*-centric overloads. The location-centric overloads are suitable to use from the diagnostic subsystem. The rest can be used from the front ends and the middle end. Add support for per-location warning groups. gcc/ChangeLog: * Makefile.in (OBJS-libcommon): Add diagnostic-spec.o. * gengtype.c (open_base_files): Add diagnostic-spec.h. * diagnostic-spec.c: New file. * diagnostic-spec.h: New file. * warning-control.cc: New file. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 1164554e6d6..b7bbcb60051 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1696,6 +1696,7 @@ OBJS = \ vmsdbgout.o \ vr-values.o \ vtable-verify.o \ + warning-control.o \ web.o \ wide-int.o \ wide-int-print.o \ @@ -1707,8 +1708,8 @@ OBJS = \ # Objects in libcommon.a, potentially used by all host binaries and with # no target dependencies. -OBJS-libcommon = diagnostic.o diagnostic-color.o diagnostic-show-locus.o \ - diagnostic-format-json.o json.o \ +OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \ + diagnostic-show-locus.o diagnostic-format-json.o json.o \ edit-context.o \ pretty-print.o intl.o \ sbitmap.o \ @@ -2648,6 +2649,7 @@ GTFILES = $(CPPLIB_H) $(srcdir)/input.h $(srcdir)/coretypes.h \ $(srcdir)/ipa-modref.h $(srcdir)/ipa-modref.c \ $(srcdir)/ipa-modref-tree.h \ $(srcdir)/signop.h \ + $(srcdir)/diagnostic-spec.h $(srcdir)/diagnostic-spec.c \ $(srcdir)/dwarf2out.h \ $(srcdir)/dwarf2asm.c \ $(srcdir)/dwarf2cfi.c \ diff --git a/gcc/diagnostic-spec.c b/gcc/diagnostic-spec.c new file mode 100644 index 00000000000..582ae3f3fe2 --- /dev/null +++ b/gcc/diagnostic-spec.c @@ -0,0 +1,172 @@ +/* Functions to enable and disable individual warnings on an expression + and statement basis. + Copyright (C) 2021 Free Software Foundation, Inc. + Contributed by Martin Sebor + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3, or (at your option) any later + version. + + GCC is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "backend.h" +#include "bitmap.h" +#include "tree.h" +#include "cgraph.h" +#include "hash-map.h" +#include "diagnostic-spec.h" +#include "pretty-print.h" + +/* Initialize *THIS from warning option OPT. */ + +nowarn_spec_t::nowarn_spec_t (int opt) +{ + /* Create a very simple mapping based on testing and experience. + It should become more refined with time. */ + switch (opt) + { + case 0: + case -1: + bits = opt; + break; + + /* Flow-sensitive warnings about pointer problems issued by both + front ends and the middle end. */ + case OPT_Waddress: + case OPT_Wnonnull: + bits = NW_NONNULL; + break; + + /* Flow-sensitive warnings about arithmetic overflow issued by both + front ends and the middle end. */ + case OPT_Woverflow: + case OPT_Wshift_count_negative: + case OPT_Wshift_count_overflow: + case OPT_Wstrict_overflow: + bits = NW_VFLOW; + break; + + /* Lexical warnings issued by front ends. */ + case OPT_Wabi: + case OPT_Wlogical_op: + case OPT_Wparentheses: + case OPT_Wreturn_type: + case OPT_Wsizeof_array_div: + case OPT_Wstrict_aliasing: + case OPT_Wunused: + case OPT_Wunused_function: + case OPT_Wunused_but_set_variable: + case OPT_Wunused_variable: + case OPT_Wunused_but_set_parameter: + bits = NW_LEXICAL; + break; + + /* Access warning group. */ + case OPT_Warray_bounds: + case OPT_Warray_bounds_: + case OPT_Wformat_overflow_: + case OPT_Wformat_truncation_: + case OPT_Wrestrict: + case OPT_Wstrict_aliasing_: + case OPT_Wstringop_overflow_: + case OPT_Wstringop_overread: + case OPT_Wstringop_truncation: + bits = NW_ACCESS; + break; + + /* Initialization warning group. */ + case OPT_Winit_self: + case OPT_Wuninitialized: + case OPT_Wmaybe_uninitialized: + bits = NW_UNINIT; + break; + + default: + /* A catchall group for everything else. */ + bits = NW_OTHER; + } +} + +/* Map from location to its no-warning disposition. */ + +GTY(()) xint_hash_map_t *nowarn_map; + +/* Return the no-warning disposition for location LOC and option OPT + or for all/any otions by default. */ + +bool +get_no_warning (location_t loc, int opt /* = -1 */) +{ + if (!nowarn_map) + return false; + + if (const nowarn_spec_t* const pspec = nowarn_map->get (loc)) + { + const nowarn_spec_t optspec (opt); + return *pspec & optspec; + } + + return false; +} + +/* Set the no-warning disposition for location LOC and option OPT when + DIS is true, or clear it when it's false. Return true if LOC has any + warnings disabled at the end of processing. */ + +bool +set_no_warning (location_t loc, int opt /* = -1 */, bool dis /* = true */) +{ + const nowarn_spec_t optspec (dis ? opt : 0); + + if (nowarn_spec_t *pspec = nowarn_map ? nowarn_map->get (loc) : NULL) + { + if (dis) + { + *pspec |= optspec; + return true; + } + + *pspec &= optspec; + if (*pspec) + return true; + + nowarn_map->remove (loc); + return false; + } + + if (!dis) + return false; + + if (!nowarn_map) + nowarn_map = xint_hash_map_t::create_ggc (32); + + nowarn_map->put (loc, optspec); + return true; +} + +/* Copy the no-warning disposition from one location to another. */ + +void +copy_no_warning (location_t to, location_t from) +{ + if (!nowarn_map) + return; + + if (nowarn_spec_t *pspec = nowarn_map->get (from)) + nowarn_map->put (to, *pspec); + else + nowarn_map->remove (to); +} diff --git a/gcc/diagnostic-spec.h b/gcc/diagnostic-spec.h new file mode 100644 index 00000000000..e0c02753923 --- /dev/null +++ b/gcc/diagnostic-spec.h @@ -0,0 +1,140 @@ +/* Language-independent APIs to enable/disable per-location warnings. + + Copyright (C) 2021 Free Software Foundation, Inc. + Contributed by Martin Sebor + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3, or (at your option) any later + version. + + GCC is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#ifndef DIAGNOSTIC_SPEC_H_INCLUDED +#define DIAGNOSTIC_SPEC_H_INCLUDED + +#include "hash-map.h" + +/* A "bitset" of warning groups. */ + +struct nowarn_spec_t +{ + enum + { + /* Middle end warnings about invalid accesses. */ + NW_ACCESS = 1 << 0, + /* Front end/lexical warnings. */ + NW_LEXICAL = 1 << 1, + /* Warnings about null pointers. */ + NW_NONNULL = 1 << 2, + /* Warnings about uninitialized reads. */ + NW_UNINIT = 1 << 3, + /* Warnings about arithmetic overflow. */ + NW_VFLOW = 1 << 4, + /* All other unclassified warnings. */ + NW_OTHER = 1 << 5, + /* All groups of warnings. */ + NW_ALL = (NW_ACCESS | NW_LEXICAL | NW_NONNULL + | NW_UNINIT | NW_VFLOW | NW_OTHER) + }; + + nowarn_spec_t (): bits () { } + + nowarn_spec_t (int); + + /* Return the raw bitset. */ + operator unsigned() const + { + return bits; + } + + /* Return true if the bitset is clear. */ + bool operator!() const + { + return !bits; + } + + /* Return the inverse of the bitset. */ + nowarn_spec_t operator~() const + { + nowarn_spec_t res (*this); + res.bits &= ~NW_ALL; + return res; + } + + /* Set *THIS to the bitwise OR of *THIS and RHS. */ + nowarn_spec_t& operator|= (const nowarn_spec_t &rhs) + { + bits |= rhs.bits; + return *this; + } + + /* Set *THIS to the bitwise AND of *THIS and RHS. */ + nowarn_spec_t& operator&= (const nowarn_spec_t &rhs) + { + bits &= rhs.bits; + return *this; + } + + /* Set *THIS to the bitwise exclusive OR of *THIS and RHS. */ + nowarn_spec_t& operator^= (const nowarn_spec_t &rhs) + { + bits ^= rhs.bits; + return *this; + } + +private: + /* Bitset of warning groups. */ + unsigned bits; +}; + +/* Return the bitwise OR of LHS and RHS. */ + +inline nowarn_spec_t +operator| (const nowarn_spec_t &lhs, const nowarn_spec_t &rhs) +{ + return nowarn_spec_t (lhs) |= rhs; +} + +/* Return the bitwise AND of LHS and RHS. */ + +inline nowarn_spec_t +operator& (const nowarn_spec_t &lhs, const nowarn_spec_t &rhs) +{ + return nowarn_spec_t (lhs) &= rhs; +} + +/* Return true if LHS is equal RHS. */ + +inline bool +operator== (const nowarn_spec_t &lhs, const nowarn_spec_t &rhs) +{ + return static_cast(lhs) == static_cast(rhs); +} + +/* Return true if LHS is not equal RHS. */ + +inline bool +operator!= (const nowarn_spec_t &lhs, const nowarn_spec_t &rhs) +{ + return !(lhs == rhs); +} + +typedef location_t key_type_t; +typedef int_hash xint_hash_t; +typedef hash_map xint_hash_map_t; + +/* A mapping from the location of an expression to the warning spec + set for it. */ +extern GTY(()) xint_hash_map_t *nowarn_map; + +#endif // DIAGNOSTIC_SPEC_H_INCLUDED diff --git a/gcc/gengtype.c b/gcc/gengtype.c index b94e2f126ec..c1fa6d35c87 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -1727,7 +1727,7 @@ open_base_files (void) "target-globals.h", "ipa-ref.h", "cgraph.h", "symbol-summary.h", "ipa-prop.h", "ipa-fnsummary.h", "dwarf2out.h", "omp-general.h", "omp-offload.h", "ipa-modref-tree.h", "ipa-modref.h", "symtab-thunks.h", - "symtab-clones.h", + "symtab-clones.h", "diagnostic-spec.h", NULL }; const char *const *ifp; diff --git a/gcc/warning-control.cc b/gcc/warning-control.cc new file mode 100644 index 00000000000..73147b618ad --- /dev/null +++ b/gcc/warning-control.cc @@ -0,0 +1,230 @@ +/* Functions to enable and disable individual warnings on an expression + and statement basis. + + Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3, or (at your option) any later + version. + + GCC is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "backend.h" +#include "bitmap.h" +#include "tree.h" +#include "gimple.h" +#include "cgraph.h" +#include "hash-map.h" +#include "diagnostic-spec.h" + +/* Return the no-warning bit for EXPR. */ + +static inline bool +get_no_warning_bit (const_tree expr) +{ + return expr->base.nowarning_flag; +} + +/* Return the no-warning bit for statement STMT. */ + +static inline bool +get_no_warning_bit (const gimple *stmt) +{ + return stmt->no_warning; +} + +/* Set the no-warning bit for EXPR to VALUE. */ + +static inline void +set_no_warning_bit (tree expr, bool value) +{ + expr->base.nowarning_flag = value; +} + +/* Set the no-warning bit for statement STMT to VALUE. */ + +static inline void +set_no_warning_bit (gimple *stmt, bool value) +{ + stmt->no_warning = value; +} + +/* Return EXPR location of zero. */ + +static inline key_type_t +convert_to_key (const_tree expr) +{ + if (DECL_P (expr)) + return DECL_SOURCE_LOCATION (expr); + if (EXPR_P (expr)) + return EXPR_LOCATION (expr); + return 0; +} + +/* Return STMT location (may be zero). */ + +static inline key_type_t +convert_to_key (const gimple *stmt) +{ + return gimple_location (stmt); +} + +/* Return the no-warning bitmap for decl/expression EXPR. */ + +static nowarn_spec_t* +get_nowarn_spec (const_tree expr) +{ + const key_type_t key = convert_to_key (expr); + + if (!get_no_warning_bit (expr) || !key) + return NULL; + + return nowarn_map ? nowarn_map->get (key) : NULL; +} + +/* Return the no-warning bitmap for stateemt STMT. */ + +static nowarn_spec_t* +get_nowarn_spec (const gimple *stmt) +{ + const key_type_t key = convert_to_key (stmt); + + if (!get_no_warning_bit (stmt)) + return NULL; + + return nowarn_map ? nowarn_map->get (key) : NULL; +} + +/* Return true if warning OPT is enabled for decl/expression EXPR. + The wildcard OPT of -1 tests for all warnings being disabled. */ + +bool +get_no_warning (const_tree expr, int opt /* = -1 */) +{ + const nowarn_spec_t *spec = get_nowarn_spec (expr); + + if (!spec) + return get_no_warning_bit (expr); + + nowarn_spec_t optspec (opt); + bool dis = *spec & optspec; + gcc_assert (get_no_warning_bit (expr) || !dis); + return dis; +} + +/* Return true if warning OPT is enabled for statement STMT. + The wildcard OPT of -1 tests for all warnings being disabled. */ + +bool +get_no_warning (const gimple *stmt, int opt /* = -1 */) +{ + const nowarn_spec_t *spec = get_nowarn_spec (stmt); + + if (!spec) + /* Fall back on the single no-warning bit. */ + return get_no_warning_bit (stmt); + + nowarn_spec_t optspec (opt); + bool dis = *spec & optspec; + gcc_assert (get_no_warning_bit (stmt) || !dis); + return dis; +} + +/* Enable, or by default disable, a warning for the expression. + The wildcard OPT of -1 controls all warnings. */ + +void +set_no_warning (tree expr, int opt /* = -1 */, bool dis /* = true */) +{ + const key_type_t key = convert_to_key (expr); + + dis = set_no_warning (key, opt, dis) || dis; + set_no_warning_bit (expr, dis); +} + +/* Enable, or by default disable, a warning for the statement STMT. + The wildcard OPT of -1 controls all warnings. */ + +void +set_no_warning (gimple *stmt, int opt /* = -1 */, bool dis /* = true */) +{ + const key_type_t key = convert_to_key (stmt); + const nowarn_spec_t optspec (opt); + dis = set_no_warning (key, opt, dis) || dis; + set_no_warning_bit (stmt, dis); +} + +/* Copy the warning disposition mapping between an expression and/or + a statement. */ + +template +void copy_no_warning (ToType to, FromType from) +{ + const key_type_t to_key = convert_to_key (to); + + if (nowarn_spec_t *from_map = get_nowarn_spec (from)) + { + /* If there's an entry in the map the no-warning bit must be set. */ + gcc_assert (get_no_warning_bit (from)); + + if (!nowarn_map) + nowarn_map = xint_hash_map_t::create_ggc (32); + + nowarn_map->put (to_key, *from_map); + set_no_warning_bit (to, true); + } + else + { + if (nowarn_map) + nowarn_map->remove (to_key); + + /* The no-warning bit might be set even if there's no entry + in the map. */ + set_no_warning_bit (to, get_no_warning_bit (from)); + } +} + +/* Copy the warning disposition mapping from one expression to another. */ + +void +copy_no_warning (tree to, const_tree from) +{ + copy_no_warning(to, from); +} + +/* Copy the warning disposition mapping from a statement to an expression. */ + +void +copy_no_warning (tree to, const gimple *from) +{ + copy_no_warning(to, from); +} + +/* Copy the warning disposition mapping from an expression to a statement. */ + +void +copy_no_warning (gimple *to, const_tree from) +{ + copy_no_warning(to, from); +} + +/* Copy the warning disposition mapping from one statement to another. */ + +void +copy_no_warning (gimple *to, const gimple *from) +{ + copy_no_warning(to, from); +} From patchwork Mon May 24 22:09:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482982 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=w310msN2; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FprwK2G6Qz9sRN for ; Tue, 25 May 2021 08:09:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8EB90385481A; Mon, 24 May 2021 22:09:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EB90385481A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621894158; bh=vx96JAb0MK3xnsCci0PfjDpPfmsjvc7r3G3pGLb+4cE=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=w310msN2Ujf+/84as+46S6vS7XD48wuPoJ0KP5M3MS1kbVIDyRmKP47QRggbS/0BA eSttXUVLs46UNtDwdp3Pkbl+ZANVtfhKVjIglXtA6uKNOR9YL1/SymrM1S7lJGrVa0 KXEuNR+CgyR/38wV4h/P/4W295D2TjVT1Xg532vg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by sourceware.org (Postfix) with ESMTPS id CB3193858022 for ; Mon, 24 May 2021 22:09:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CB3193858022 Received: by mail-oi1-x22c.google.com with SMTP id x15so28397873oic.13 for ; Mon, 24 May 2021 15:09:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=vx96JAb0MK3xnsCci0PfjDpPfmsjvc7r3G3pGLb+4cE=; b=WG4RUcngXBnHxmC4s0lpUaFyj6Osc58D9kO7OIM5bI8UnC9C5bwGHMcQfrajwEZGK0 IffnIxPkBXCsH2OwI54lYAdO6ApNIL8oHqrRkZkPUZeuld0YaJne2lZ+gyNuSPIMyjDc zRC1Q7SwgV1p3HJf0Q9G6x+E0btaSaDF8XaISM52+HD5nxBU872Y81iTHu8xgAukWLg5 fSTEGhOlCFPTPFWGJG2MxRC2p+Kltz7Ae4DLijgsce+O1PpW/ZglDO9/OT8JXA4iQfUl /j0H/C0wCe5bGLmLhBdip8ZirKhjfHlr82OFkib28czZdU9ImLEejFyIQi8fnBnaKJgd tuFQ== X-Gm-Message-State: AOAM532I69jZMRrzCHpKnyfF2FB+RDKyZzzlsh4c4gY3W6LU3Z6irvK1 EYDgtSefj7miH30DpOhlnK93VuoPQgw= X-Google-Smtp-Source: ABdhPJzkIQ373MqrhqtlfhP1PYkkCdXx+sH1muq+8UJtm3bPzq8Ky8WMjyIdKEPAC/Ai9So2tqNz0g== X-Received: by 2002:a05:6808:143:: with SMTP id h3mr12300526oie.96.1621894156148; Mon, 24 May 2021 15:09:16 -0700 (PDT) Received: from [192.168.0.41] (174-16-126-108.hlrn.qwest.net. [174.16.126.108]) by smtp.gmail.com with ESMTPSA id w6sm3376296otj.5.2021.05.24.15.09.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 May 2021 15:09:15 -0700 (PDT) Subject: [PATCH 2/11] use xxx_no_warning APIs in Ada To: gcc-patches References: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Message-ID: Date: Mon, 24 May 2021 16:09:14 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Content-Language: en-US X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" [PATCH 2/11] use xxx_no_warning APIs in Ada. Add support for per-location warning groups. gcc/ada/ChangeLog: * gcc-interface/trans.c (Handled_Sequence_Of_Statements_to_gnu): Replace TREE_NO_WARNING with set_no_warning. (gnat_gimplify_expr): Same. * gcc-interface/utils.c (gnat_pushdecl): Same. diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 9aeaf038118..63d662669ef 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -5357,7 +5357,7 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node) because of the unstructured form of EH used by fe_sjlj_eh, there might be forward edges going to __builtin_setjmp receivers on which it is uninitialized, although they will never be actually taken. */ - TREE_NO_WARNING (gnu_jmpsave_decl) = 1; + set_no_warning (gnu_jmpsave_decl, OPT_Wuninitialized); gnu_jmpbuf_decl = create_var_decl (get_identifier ("JMP_BUF"), NULL_TREE, jmpbuf_type, @@ -8792,7 +8792,7 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p, else { *expr_p = create_tmp_var (type, NULL); - TREE_NO_WARNING (*expr_p) = 1; + set_no_warning (*expr_p); } gimplify_and_add (TREE_OPERAND (expr, 0), pre_p); diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 80a4160adf3..7d08ae9193a 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -836,7 +836,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) if (!deferred_decl_context) DECL_CONTEXT (decl) = context; - TREE_NO_WARNING (decl) = (No (gnat_node) || Warnings_Off (gnat_node)); + set_no_warning (decl, (No (gnat_node) || Warnings_Off (gnat_node))); /* Set the location of DECL and emit a declaration for it. */ if (Present (gnat_node) && !renaming_from_instantiation_p (gnat_node)) From patchwork Mon May 24 22:10:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482983 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=eNGxTsmB; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FprxQ225dz9s24 for ; Tue, 25 May 2021 08:10:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 413F4388A409; Mon, 24 May 2021 22:10:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 413F4388A409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621894216; bh=O1HSRQcn/YUKpcWXvEc5Z3IqqDvwpc1xB/c1ujxws30=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eNGxTsmBW2Xry9D5XIOjn0jGgHjSbpeF4Kvnqlv3db3bh26j9PBuFXDq+EHyYFTb/ XJEl6akLegeDZ4uHuLOaJgqWzznj+kb8NZQzqrihbJ+XPzd5dlnadxP78rYU3Amof+ w3qg4T5Vosm7qerVd/ZEPmoquvcFvCFqCeL+6dFg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 98FC73858022 for ; Mon, 24 May 2021 22:10:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 98FC73858022 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-473-1AgiPl-tPymZC3VccGG_vw-1; Mon, 24 May 2021 18:10:09 -0400 X-MC-Unique: 1AgiPl-tPymZC3VccGG_vw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDF9B189C440 for ; Mon, 24 May 2021 22:10:08 +0000 (UTC) Received: from [10.3.114.34] (ovpn-114-34.phx2.redhat.com [10.3.114.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C7225946E for ; Mon, 24 May 2021 22:10:08 +0000 (UTC) Subject: [PATCH 3/11] use xxx_no_warning APIs in C To: gcc-patches References: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Message-ID: <8f003684-44f7-ab8f-6c47-a03682411287@redhat.com> Date: Mon, 24 May 2021 16:10:08 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The attached patch replaces the uses of TREE_NO_WARNING in the C front end. Add support for per-location warning groups. gcc/c/ChangeLog: * c-decl.c (pop_scope): Replace direct uses of TREE_NO_WARNING with get_no_warning, set_no_warning, and copy_no_warning. (diagnose_mismatched_decls): Same. (duplicate_decls): Same. (grokdeclarator): Same. (finish_function): Same. (c_write_global_declarations_1): Same. * c-fold.c (c_fully_fold_internal): Same. * c-parser.c (c_parser_expr_no_commas): Same. (c_parser_postfix_expression): Same. * c-typeck.c (array_to_pointer_conversion): Same. (function_to_pointer_conversion): Same. (default_function_array_conversion): Same. (convert_lvalue_to_rvalue): Same. (default_conversion): Same. (build_indirect_ref): Same. (build_function_call_vec): Same. (build_atomic_assign): Same. (build_unary_op): Same. (c_finish_return): Same. (emit_side_effect_warnings): Same. (c_finish_stmt_expr): Same. (c_omp_clause_copy_ctor): Same. diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 53b2b5b637d..800f08ed7b9 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -1295,7 +1295,7 @@ pop_scope (void) case VAR_DECL: /* Warnings for unused variables. */ if ((!TREE_USED (p) || !DECL_READ_P (p)) - && !TREE_NO_WARNING (p) + && !get_no_warning (p, OPT_Wunused_but_set_variable) && !DECL_IN_SYSTEM_HEADER (p) && DECL_NAME (p) && !DECL_ARTIFICIAL (p) @@ -2159,8 +2159,8 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, if (DECL_IN_SYSTEM_HEADER (newdecl) || DECL_IN_SYSTEM_HEADER (olddecl) - || TREE_NO_WARNING (newdecl) - || TREE_NO_WARNING (olddecl)) + || get_no_warning (newdecl, OPT_Wpedantic) + || get_no_warning (olddecl, OPT_Wpedantic)) return true; /* Allow OLDDECL to continue in use. */ if (variably_modified_type_p (newtype, NULL)) @@ -2953,7 +2953,7 @@ duplicate_decls (tree newdecl, tree olddecl) if (!diagnose_mismatched_decls (newdecl, olddecl, &newtype, &oldtype)) { /* Avoid `unused variable' and other warnings for OLDDECL. */ - TREE_NO_WARNING (olddecl) = 1; + set_no_warning (olddecl, OPT_Wunused); return false; } @@ -7540,10 +7540,7 @@ grokdeclarator (const struct c_declarator *declarator, FIELD_DECL, declarator->u.id.id, type); DECL_NONADDRESSABLE_P (decl) = bitfield; if (bitfield && !declarator->u.id.id) - { - TREE_NO_WARNING (decl) = 1; - DECL_PADDING_P (decl) = 1; - } + DECL_PADDING_P (decl) = 1; if (size_varies) C_DECL_VARIABLE_SIZE (decl) = 1; @@ -10225,7 +10222,7 @@ finish_function (location_t end_loc) && targetm.warn_func_return (fndecl) && warning (OPT_Wreturn_type, "no return statement in function returning non-void")) - TREE_NO_WARNING (fndecl) = 1; + set_no_warning (fndecl, OPT_Wreturn_type); /* Complain about parameters that are only set, but never otherwise used. */ if (warn_unused_but_set_parameter) @@ -10240,7 +10237,7 @@ finish_function (location_t end_loc) && !DECL_READ_P (decl) && DECL_NAME (decl) && !DECL_ARTIFICIAL (decl) - && !TREE_NO_WARNING (decl)) + && !get_no_warning (decl, OPT_Wunused_but_set_parameter)) warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_but_set_parameter, "parameter %qD set but not used", decl); @@ -12106,19 +12103,20 @@ c_write_global_declarations_1 (tree globals) { if (C_DECL_USED (decl)) { + /* TODO: Add OPT_Wundefined-inline. */ if (pedwarn (input_location, 0, "%q+F used but never defined", decl)) - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl /* OPT_Wundefined-inline. */); } /* For -Wunused-function warn about unused static prototypes. */ else if (warn_unused_function && ! DECL_ARTIFICIAL (decl) - && ! TREE_NO_WARNING (decl)) + && ! get_no_warning (decl, OPT_Wunused_function)) { if (warning (OPT_Wunused_function, "%q+F declared % but never defined", decl)) - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl, OPT_Wunused_function); } } diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c index 68c74cc1eb2..5bc90ad541b 100644 --- a/gcc/c/c-fold.c +++ b/gcc/c/c-fold.c @@ -154,7 +154,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, tree orig_op0, orig_op1, orig_op2; bool op0_const = true, op1_const = true, op2_const = true; bool op0_const_self = true, op1_const_self = true, op2_const_self = true; - bool nowarning = TREE_NO_WARNING (expr); + bool nowarning = get_no_warning (expr, OPT_Woverflow); bool unused_p; bool op0_lval = false; source_range old_range; @@ -670,13 +670,13 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, out: /* Some folding may introduce NON_LVALUE_EXPRs; all lvalue checks have been done by this point, so remove them again. */ - nowarning |= TREE_NO_WARNING (ret); + nowarning |= get_no_warning (ret, OPT_Woverflow); STRIP_TYPE_NOPS (ret); - if (nowarning && !TREE_NO_WARNING (ret)) + if (nowarning && !get_no_warning (ret, OPT_Woverflow)) { if (!CAN_HAVE_LOCATION_P (ret)) ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret); - TREE_NO_WARNING (ret) = 1; + set_no_warning (ret, OPT_Woverflow); } if (ret != expr) { diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index b9930d487fd..7c1f6840e51 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -7558,7 +7558,7 @@ c_parser_expr_no_commas (c_parser *parser, struct c_expr *after, ret.original_code = MODIFY_EXPR; else { - TREE_NO_WARNING (ret.value) = 1; + set_no_warning (ret.value, OPT_Wparentheses); ret.original_code = ERROR_MARK; } ret.original_type = NULL; @@ -9085,7 +9085,7 @@ c_parser_postfix_expression (c_parser *parser) c_parser_consume_token (parser); expr = c_parser_expression (parser); if (TREE_CODE (expr.value) == MODIFY_EXPR) - TREE_NO_WARNING (expr.value) = 1; + set_no_warning (expr.value, OPT_Wparentheses); if (expr.original_code != C_MAYBE_CONST_EXPR && expr.original_code != SIZEOF_EXPR) expr.original_code = ERROR_MARK; diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index c3b85da1125..888f0c99600 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -1911,8 +1911,7 @@ array_to_pointer_conversion (location_t loc, tree exp) STRIP_TYPE_NOPS (exp); - if (TREE_NO_WARNING (orig_exp)) - TREE_NO_WARNING (exp) = 1; + copy_no_warning (exp, orig_exp); ptrtype = build_pointer_type (restype); @@ -1945,8 +1944,7 @@ function_to_pointer_conversion (location_t loc, tree exp) STRIP_TYPE_NOPS (exp); - if (TREE_NO_WARNING (orig_exp)) - TREE_NO_WARNING (exp) = 1; + copy_no_warning (exp, orig_exp); return build_unary_op (loc, ADDR_EXPR, exp, false); } @@ -2055,8 +2053,7 @@ default_function_array_conversion (location_t loc, struct c_expr exp) exp.value = TREE_OPERAND (exp.value, 0); } - if (TREE_NO_WARNING (orig_exp)) - TREE_NO_WARNING (exp.value) = 1; + copy_no_warning (exp.value, orig_exp); lvalue_array_p = !not_lvalue && lvalue_p (exp.value); if (!flag_isoc99 && !lvalue_array_p) @@ -2154,7 +2151,8 @@ convert_lvalue_to_rvalue (location_t loc, struct c_expr exp, tmp = create_tmp_var_raw (nonatomic_type); tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, false); TREE_ADDRESSABLE (tmp) = 1; - TREE_NO_WARNING (tmp) = 1; + /* Do not disable warnings for TMP even though it's artificial. + -Winvalid-memory-model depends on it. */ /* Issue __atomic_load (&expr, &tmp, SEQ_CST); */ fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD); @@ -2251,8 +2249,7 @@ default_conversion (tree exp) orig_exp = exp; STRIP_TYPE_NOPS (exp); - if (TREE_NO_WARNING (orig_exp)) - TREE_NO_WARNING (exp) = 1; + copy_no_warning (exp, orig_exp); if (code == VOID_TYPE) { @@ -2616,7 +2613,7 @@ build_indirect_ref (location_t loc, tree ptr, ref_operator errstring) if (warn_strict_aliasing > 2) if (strict_aliasing_warning (EXPR_LOCATION (pointer), type, TREE_OPERAND (pointer, 0))) - TREE_NO_WARNING (pointer) = 1; + set_no_warning (pointer, OPT_Wstrict_aliasing_); } if (TREE_CODE (pointer) == ADDR_EXPR @@ -3218,7 +3215,7 @@ build_function_call_vec (location_t loc, vec arg_loc, /* If -Wnonnull warning has been diagnosed, avoid diagnosing it again later. */ if (warned_p && TREE_CODE (result) == CALL_EXPR) - TREE_NO_WARNING (result) = 1; + set_no_warning (result, OPT_Wnonnull); /* In this improbable scenario, a nested function returns a VM type. Create a TARGET_EXPR so that the call always has a LHS, much as @@ -4167,7 +4164,7 @@ build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode, TYPE_UNQUALIFIED); val = create_tmp_var_raw (nonatomic_rhs_type); TREE_ADDRESSABLE (val) = 1; - TREE_NO_WARNING (val) = 1; + set_no_warning (val); rhs = build4 (TARGET_EXPR, nonatomic_rhs_type, val, rhs, NULL_TREE, NULL_TREE); TREE_SIDE_EFFECTS (rhs) = 1; @@ -4268,7 +4265,7 @@ build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode, newval = create_tmp_var_raw (nonatomic_lhs_type); TREE_ADDRESSABLE (newval) = 1; - TREE_NO_WARNING (newval) = 1; + set_no_warning (newval); rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, func_call, NULL_TREE, NULL_TREE); SET_EXPR_LOCATION (rhs, loc); @@ -4287,12 +4284,12 @@ cas_loop: old = create_tmp_var_raw (nonatomic_lhs_type); old_addr = build_unary_op (loc, ADDR_EXPR, old, false); TREE_ADDRESSABLE (old) = 1; - TREE_NO_WARNING (old) = 1; + set_no_warning (old); newval = create_tmp_var_raw (nonatomic_lhs_type); newval_addr = build_unary_op (loc, ADDR_EXPR, newval, false); TREE_ADDRESSABLE (newval) = 1; - TREE_NO_WARNING (newval) = 1; + set_no_warning (newval); loop_decl = create_artificial_label (loc); loop_label = build1 (LABEL_EXPR, void_type_node, loop_decl); @@ -4781,8 +4778,6 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, else val = build2 (code, TREE_TYPE (arg), arg, inc); TREE_SIDE_EFFECTS (val) = 1; - if (TREE_CODE (val) != code) - TREE_NO_WARNING (val) = 1; ret = val; goto return_build_unary_op; } @@ -10941,7 +10936,8 @@ c_finish_return (location_t loc, tree retval, tree origtype) } ret_stmt = build_stmt (loc, RETURN_EXPR, retval); - TREE_NO_WARNING (ret_stmt) |= no_warning; + if (no_warning) + set_no_warning (ret_stmt, OPT_Wreturn_type); return add_stmt (ret_stmt); } @@ -11217,7 +11213,8 @@ emit_side_effect_warnings (location_t loc, tree expr) ; else if (!TREE_SIDE_EFFECTS (expr)) { - if (!VOID_TYPE_P (TREE_TYPE (expr)) && !TREE_NO_WARNING (expr)) + if (!VOID_TYPE_P (TREE_TYPE (expr)) + && !get_no_warning (expr, OPT_Wunused_value)) warning_at (loc, OPT_Wunused_value, "statement with no effect"); } else if (TREE_CODE (expr) == COMPOUND_EXPR) @@ -11233,8 +11230,8 @@ emit_side_effect_warnings (location_t loc, tree expr) if (!TREE_SIDE_EFFECTS (r) && !VOID_TYPE_P (TREE_TYPE (r)) && !CONVERT_EXPR_P (r) - && !TREE_NO_WARNING (r) - && !TREE_NO_WARNING (expr)) + && !get_no_warning (r, OPT_Wunused_value) + && !get_no_warning (expr, OPT_Wunused_value)) warning_at (cloc, OPT_Wunused_value, "right-hand operand of comma expression has no effect"); } @@ -11403,7 +11400,7 @@ c_finish_stmt_expr (location_t loc, tree body) last = c_wrap_maybe_const (last, true); /* Do not warn if the return value of a statement expression is unused. */ - TREE_NO_WARNING (last) = 1; + set_no_warning (last, OPT_Wunused); return last; } @@ -15368,7 +15365,7 @@ c_omp_clause_copy_ctor (tree clause, tree dst, tree src) tree tmp = create_tmp_var (nonatomic_type); tree tmp_addr = build_fold_addr_expr (tmp); TREE_ADDRESSABLE (tmp) = 1; - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tree src_addr = build_fold_addr_expr (src); tree dst_addr = build_fold_addr_expr (dst); tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST); From patchwork Mon May 24 22:11:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=gPN4sSI8; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FpryS3w55z9s24 for ; Tue, 25 May 2021 08:11:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7048B388A409; Mon, 24 May 2021 22:11:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7048B388A409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621894270; bh=G2B0Y0ePMqoOvdLIevPcdJZCr37prIZGCAZX+8Jf7zs=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=gPN4sSI8eKbGm0+pPIQQqkQwCYjuLE11nFIUIeQYyTaxyNvzDzSytn7IQUfg70yCw WnIqJTCI+U2c6Ya5qU3HSWwnUIU7DpR8sUAXeG4goh/xURKS7+2zNFQxxpod3i8T9f /dPpeKx6Q+2bvOMlIsBbjVDmhzAgRMEiBApA0cKs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id CFCC53858022 for ; Mon, 24 May 2021 22:11:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CFCC53858022 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-89-BsG7JzugMxmeV3XcV3JYFA-1; Mon, 24 May 2021 18:11:04 -0400 X-MC-Unique: BsG7JzugMxmeV3XcV3JYFA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF22F107ACCD for ; Mon, 24 May 2021 22:11:03 +0000 (UTC) Received: from [10.3.114.34] (ovpn-114-34.phx2.redhat.com [10.3.114.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE04450F1A for ; Mon, 24 May 2021 22:11:03 +0000 (UTC) Subject: [PATCH 4/11] use xxx_no_warning APIs in C family To: gcc-patches References: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Message-ID: <98347462-6e87-53d8-d69d-73f3f0cb6396@redhat.com> Date: Mon, 24 May 2021 16:11:03 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The attached patch replaces the uses of TREE_NO_WARNING in the C family common subset of the C and C++ front ends. Add support for per-location warning groups. gcc/c-family/ChangeLog: * c-common.c (c_wrap_maybe_const): Remove TREE_NO_WARNING. (c_common_truthvalue_conversion): Replace direct uses of TREE_NO_WARNING with get_no_warning, set_no_warning, and copy_no_warning. (check_function_arguments_recurse): Same. * c-gimplify.c (c_gimplify_expr): Same. * c-warn.c (overflow_warning): Same. (warn_logical_operator): Same. (warn_if_unused_value): Same. (do_warn_unused_parameter): Same. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index b7daa2e2654..a97376c5fd1 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -3236,7 +3236,6 @@ pointer_int_sum (location_t loc, enum tree_code resultcode, tree c_wrap_maybe_const (tree expr, bool non_const) { - bool nowarning = TREE_NO_WARNING (expr); location_t loc = EXPR_LOCATION (expr); /* This should never be called for C++. */ @@ -3247,8 +3246,6 @@ c_wrap_maybe_const (tree expr, bool non_const) STRIP_TYPE_NOPS (expr); expr = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (expr), NULL, expr); C_MAYBE_CONST_EXPR_NON_CONST (expr) = non_const; - if (nowarning) - TREE_NO_WARNING (expr) = 1; protected_set_expr_location (expr, loc); return expr; @@ -3494,12 +3491,12 @@ c_common_truthvalue_conversion (location_t location, tree expr) break; case MODIFY_EXPR: - if (!TREE_NO_WARNING (expr) + if (!get_no_warning (expr, OPT_Wparentheses) && warn_parentheses && warning_at (location, OPT_Wparentheses, "suggest parentheses around assignment used as " "truth value")) - TREE_NO_WARNING (expr) = 1; + set_no_warning (expr, OPT_Wparentheses); break; case CONST_DECL: @@ -5880,7 +5877,7 @@ check_function_arguments_recurse (void (*callback) void *ctx, tree param, unsigned HOST_WIDE_INT param_num) { - if (TREE_NO_WARNING (param)) + if (get_no_warning (param)) return; if (CONVERT_EXPR_P (param) diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c index 39c969d8f40..8a6b36fc846 100644 --- a/gcc/c-family/c-gimplify.c +++ b/gcc/c-family/c-gimplify.c @@ -713,7 +713,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED, && !TREE_STATIC (DECL_EXPR_DECL (*expr_p)) && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL (*expr_p)) && !warn_init_self) - TREE_NO_WARNING (DECL_EXPR_DECL (*expr_p)) = 1; + set_no_warning (DECL_EXPR_DECL (*expr_p), OPT_Winit_self); break; case PREINCREMENT_EXPR: diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index c48dc2e6d24..2af2bc0a43f 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -155,7 +155,7 @@ overflow_warning (location_t loc, tree value, tree expr) value); if (warned) - TREE_NO_WARNING (value) = 1; + set_no_warning (value, OPT_Woverflow); } /* Helper function for walk_tree. Unwrap C_MAYBE_CONST_EXPRs in an expression @@ -219,7 +219,7 @@ warn_logical_operator (location_t location, enum tree_code code, tree type, && INTEGRAL_TYPE_P (TREE_TYPE (op_left)) && !CONSTANT_CLASS_P (stripped_op_left) && TREE_CODE (stripped_op_left) != CONST_DECL - && !TREE_NO_WARNING (op_left) + && !get_no_warning (op_left, OPT_Wlogical_op) && TREE_CODE (op_right) == INTEGER_CST && !integer_zerop (op_right) && !integer_onep (op_right)) @@ -234,7 +234,7 @@ warn_logical_operator (location_t location, enum tree_code code, tree type, = warning_at (location, OPT_Wlogical_op, "logical % applied to non-boolean constant"); if (warned) - TREE_NO_WARNING (op_left) = true; + set_no_warning (op_left, OPT_Wlogical_op); return; } @@ -588,7 +588,7 @@ bool warn_if_unused_value (const_tree exp, location_t locus, bool quiet) { restart: - if (TREE_USED (exp) || TREE_NO_WARNING (exp)) + if (TREE_USED (exp) || get_no_warning (exp, OPT_Wunused_value)) return false; /* Don't warn about void constructs. This includes casting to void, @@ -2422,7 +2422,7 @@ do_warn_unused_parameter (tree fn) decl; decl = DECL_CHAIN (decl)) if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL && DECL_NAME (decl) && !DECL_ARTIFICIAL (decl) - && !TREE_NO_WARNING (decl)) + && !get_no_warning (decl, OPT_Wunused_parameter)) warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_parameter, "unused parameter %qD", decl); } From patchwork Mon May 24 22:11:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=G3blAv6P; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FprzT1tQBz9s24 for ; Tue, 25 May 2021 08:12:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 215ED388A409; Mon, 24 May 2021 22:12:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 215ED388A409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621894323; bh=PY2ihdh2PYImXb9JFWtthyHcT2Qncf2Vc4By5UHOOBg=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=G3blAv6PTI7sv6bdeQERLCBEwOx0IoDqpGdq+YvA95umD9eYgFJ+6xZ8oAmESDikF CRqYnvLgWyaCdpdl+qbZnFDaZQbty0gDO+sK3W28kLePGY16iM+Zjwz9h6S6E013KA Q37OYjsqArUrn4MPUCrANj89iaiKaLSF4gLdhlsI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 2A02A3853836 for ; Mon, 24 May 2021 22:11:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2A02A3853836 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-548-_sWC_DSDMMaZwVSC6nMUKA-1; Mon, 24 May 2021 18:11:54 -0400 X-MC-Unique: _sWC_DSDMMaZwVSC6nMUKA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BBB3A107ACF5 for ; Mon, 24 May 2021 22:11:53 +0000 (UTC) Received: from [10.3.114.34] (ovpn-114-34.phx2.redhat.com [10.3.114.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5761118AD4; Mon, 24 May 2021 22:11:53 +0000 (UTC) Subject: [PATCH 5/11] use xxx_no_warning APIs in C++ To: gcc-patches , Jason Merrill References: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Message-ID: Date: Mon, 24 May 2021 16:11:53 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_SBL, URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The attached patch replaces the uses of TREE_NO_WARNING in the C++ front end. For the set/get_no_warning calls I tried to find the most appropriate option to disable and query. In some cases there are helpful comments nearby that made this easy. In other cases it was less straightforward, and in some I didn't know. In some of those, disabling all warnings may be what we want, but in others we might want to be more selective to further improve efficacy. Add support for per-location warning groups. * call.c (build_over_call): Replace direct uses of TREE_NO_WARNING with get_no_warning, set_no_warning, and copy_no_warning, or nothing if not necessary. (set_up_extended_ref_temp): Same. * class.c (layout_class_type): Same. * constraint.cc (constraint_satisfaction_value): Same. * coroutines.cc (finish_co_await_expr): Same. (finish_co_yield_expr): Same. (finish_co_return_stmt): Same. (build_actor_fn): Same. (coro_rewrite_function_body): Same. (morph_fn_to_coro): Same. * cp-gimplify.c (genericize_eh_spec_block): Same. (gimplify_expr_stmt): Same. (cp_genericize_r): Same. (cp_fold): Same. * cp-ubsan.c (cp_ubsan_instrument_vptr): Same. * cvt.c (cp_fold_convert): Same. (convert_to_void): Same. * decl.c (wrapup_namespace_globals): Same. (grokdeclarator): Same. (finish_function): Same. (require_deduced_type): Same. * decl2.c (no_linkage_error): Same. (c_parse_final_cleanups): Same. * except.c (expand_end_catch_block): Same. * init.c (build_new_1): Same. (build_new): Same. (build_vec_delete_1): Same. (build_vec_init): Same. (build_delete): Same. * method.c (defaultable_fn_check): Same. * parser.c (cp_parser_fold_expression): Same. (cp_parser_primary_expression): Same. * pt.c (push_tinst_level_loc): Same. (tsubst_copy): Same. (tsubst_omp_udr): Same. (tsubst_copy_and_build): Same. * rtti.c (build_if_nonnull): Same. * semantics.c (maybe_convert_cond): Same. (finish_return_stmt): Same. (finish_parenthesized_expr): Same. (cp_check_omp_declare_reduction): Same. * tree.c (build_cplus_array_type): Same. * typeck.c (build_ptrmemfunc_access_expr): Same. (cp_build_indirect_ref_1): Same. (cp_build_function_call_vec): Same. (warn_for_null_address): Same. (cp_build_binary_op): Same. (unary_complex_lvalue): Same. (cp_build_modify_expr): Same. (build_x_modify_expr): Same. (convert_for_assignment): Same. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 4a59b97c110..2355020066a 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -9437,7 +9437,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) { /* Avoid copying empty classes. */ val = build2 (COMPOUND_EXPR, type, arg, to); - TREE_NO_WARNING (val) = 1; + set_no_warning (val, OPT_Wunused); } else if (tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (as_base))) { @@ -9468,7 +9468,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) build2 (MEM_REF, array_type, arg0, alias_set), build2 (MEM_REF, array_type, arg, alias_set)); val = build2 (COMPOUND_EXPR, TREE_TYPE (to), t, to); - TREE_NO_WARNING (val) = 1; + set_no_warning (val, OPT_Wunused); } cp_warn_deprecated_use (fn, complain); @@ -9542,7 +9542,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) { tree c = extract_call_expr (call); if (TREE_CODE (c) == CALL_EXPR) - TREE_NO_WARNING (c) = 1; + set_no_warning (c /* Suppress all warnings. */); } if (TREE_CODE (fn) == ADDR_EXPR) { @@ -12491,11 +12491,11 @@ set_up_extended_ref_temp (tree decl, tree expr, vec **cleanups, TREE_ADDRESSABLE (var) = 1; if (TREE_CODE (decl) == FIELD_DECL - && extra_warnings && !TREE_NO_WARNING (decl)) + && extra_warnings && !get_no_warning (decl)) { warning (OPT_Wextra, "a temporary bound to %qD only persists " "until the constructor exits", decl); - TREE_NO_WARNING (decl) = true; + set_no_warning (decl); } /* Recursively extend temps in this initializer. */ diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 354addde773..c3024842f87 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6689,7 +6689,7 @@ layout_class_type (tree t, tree *virtuals_p) laying out an Objective-C class. The ObjC ABI differs from the C++ ABI, and so we do not want a warning here. */ - && !TREE_NO_WARNING (field) + && !get_no_warning (field, OPT_Wabi) && !last_field_was_bitfield && !integer_zerop (size_binop (TRUNC_MOD_EXPR, DECL_FIELD_BIT_OFFSET (field), diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 03ce8eb9ff2..c30127662b5 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3281,14 +3281,14 @@ constraint_satisfaction_value (tree t, tree args, sat_info info) else r = satisfy_nondeclaration_constraints (t, args, info); if (r == error_mark_node && info.quiet () - && !(DECL_P (t) && TREE_NO_WARNING (t))) + && !(DECL_P (t) && get_no_warning (t))) { /* Replay the error noisily. */ sat_info noisy (tf_warning_or_error, info.in_decl); constraint_satisfaction_value (t, args, noisy); if (DECL_P (t) && !args) /* Avoid giving these errors again. */ - TREE_NO_WARNING (t) = true; + set_no_warning (t); } return r; } diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 71662061f5a..786bffcfad7 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -1078,7 +1078,7 @@ finish_co_await_expr (location_t kw, tree expr) is declared to return non-void (most likely). This is correct - we synthesize the return for the ramp in the compiler. So suppress any extraneous warnings during substitution. */ - TREE_NO_WARNING (current_function_decl) = true; + set_no_warning (current_function_decl, OPT_Wreturn_type); /* If we don't know the promise type, we can't proceed, build the co_await with the expression unchanged. */ @@ -1154,7 +1154,7 @@ finish_co_yield_expr (location_t kw, tree expr) is declared to return non-void (most likely). This is correct - we synthesize the return for the ramp in the compiler. So suppress any extraneous warnings during substitution. */ - TREE_NO_WARNING (current_function_decl) = true; + set_no_warning (current_function_decl, OPT_Wreturn_type); /* If we don't know the promise type, we can't proceed, build the co_await with the expression unchanged. */ @@ -1235,7 +1235,7 @@ finish_co_return_stmt (location_t kw, tree expr) is declared to return non-void (most likely). This is correct - we synthesize the return for the ramp in the compiler. So suppress any extraneous warnings during substitution. */ - TREE_NO_WARNING (current_function_decl) = true; + set_no_warning (current_function_decl, OPT_Wreturn_type); if (processing_template_decl && check_for_bare_parameter_packs (expr)) @@ -1259,7 +1259,7 @@ finish_co_return_stmt (location_t kw, tree expr) /* Suppress -Wreturn-type for co_return, we need to check indirectly whether the promise type has a suitable return_void/return_value. */ - TREE_NO_WARNING (current_function_decl) = true; + set_no_warning (current_function_decl, OPT_Wreturn_type); if (!processing_template_decl && warn_sequence_point) verify_sequence_points (expr); @@ -2459,7 +2459,7 @@ build_actor_fn (location_t loc, tree coro_frame_type, tree actor, tree fnbody, /* done. */ r = build_stmt (loc, RETURN_EXPR, NULL); - TREE_NO_WARNING (r) |= 1; /* We don't want a warning about this. */ + set_no_warning (r); /* We don't want a warning about this. */ r = maybe_cleanup_point_expr_void (r); add_stmt (r); @@ -2468,7 +2468,7 @@ build_actor_fn (location_t loc, tree coro_frame_type, tree actor, tree fnbody, add_stmt (r); r = build_stmt (loc, RETURN_EXPR, NULL); - TREE_NO_WARNING (r) |= 1; /* We don't want a warning about this. */ + set_no_warning (r); /* We don't want a warning about this. */ r = maybe_cleanup_point_expr_void (r); add_stmt (r); @@ -4144,7 +4144,7 @@ coro_rewrite_function_body (location_t fn_start, tree fnbody, tree orig, finish_if_stmt_cond (not_iarc, not_iarc_if); /* If the initial await resume called value is false, rethrow... */ tree rethrow = build_throw (fn_start, NULL_TREE); - TREE_NO_WARNING (rethrow) = true; + set_no_warning (rethrow); finish_expr_stmt (rethrow); finish_then_clause (not_iarc_if); tree iarc_scope = IF_SCOPE (not_iarc_if); @@ -4245,7 +4245,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) /* For early errors, we do not want a diagnostic about the missing ramp return value, since the user cannot fix this - a 'return' is not allowed in a coroutine. */ - TREE_NO_WARNING (orig) = true; + set_no_warning (orig, OPT_Wreturn_type); /* Discard the body, we can't process it further. */ pop_stmt_list (DECL_SAVED_TREE (orig)); DECL_SAVED_TREE (orig) = push_stmt_list (); @@ -4271,7 +4271,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) DECL_SAVED_TREE (orig) = push_stmt_list (); append_to_statement_list (fnbody, &DECL_SAVED_TREE (orig)); /* Suppress warnings about the missing return value. */ - TREE_NO_WARNING (orig) = true; + set_no_warning (orig, OPT_Wreturn_type); return false; } @@ -4950,7 +4950,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) BIND_EXPR_BODY (ramp_bind) = pop_stmt_list (ramp_body); DECL_SAVED_TREE (orig) = newbody; /* Suppress warnings about the missing return value. */ - TREE_NO_WARNING (orig) = true; + set_no_warning (orig, OPT_Wreturn_type); return false; } @@ -5161,7 +5161,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) promise_type, fn_start); finish_expr_stmt (del_coro_fr); tree rethrow = build_throw (fn_start, NULL_TREE); - TREE_NO_WARNING (rethrow) = true; + set_no_warning (rethrow); finish_expr_stmt (rethrow); finish_handler (handler); TRY_HANDLERS (ramp_cleanup) = pop_stmt_list (TRY_HANDLERS (ramp_cleanup)); diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 9079a5b90ca..2b3ec745912 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -101,8 +101,8 @@ genericize_eh_spec_block (tree *stmt_p) tree failure = build_call_n (call_unexpected_fn, 1, build_exc_ptr ()); *stmt_p = build_gimple_eh_filter_tree (body, allowed, failure); - TREE_NO_WARNING (*stmt_p) = true; - TREE_NO_WARNING (TREE_OPERAND (*stmt_p, 1)) = true; + set_no_warning (*stmt_p); + set_no_warning (TREE_OPERAND (*stmt_p, 1)); } /* Return the first non-compound statement in STMT. */ @@ -214,7 +214,7 @@ gimplify_expr_stmt (tree *stmt_p) { if (!IS_EMPTY_STMT (stmt) && !VOID_TYPE_P (TREE_TYPE (stmt)) - && !TREE_NO_WARNING (stmt)) + && !get_no_warning (stmt, OPT_Wunused_value)) warning (OPT_Wunused_value, "statement with no effect"); } else @@ -1322,7 +1322,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) case THROW_EXPR: { location_t loc = location_of (stmt); - if (TREE_NO_WARNING (stmt)) + if (get_no_warning (stmt /* What warning? */)) /* Never mind. */; else if (wtd->try_block) { @@ -2443,8 +2443,9 @@ cp_fold (tree x) ; else if (COMPARISON_CLASS_P (x)) { - if (TREE_NO_WARNING (org_x) && warn_nonnull_compare) - TREE_NO_WARNING (x) = 1; + if (warn_nonnull_compare + && get_no_warning (org_x, OPT_Wnonnull_compare)) + set_no_warning (x, OPT_Wnonnull_compare); } /* Otherwise give up on optimizing these, let GIMPLE folders optimize those later on. */ @@ -2452,8 +2453,9 @@ cp_fold (tree x) || op1 != TREE_OPERAND (org_x, 1)) { x = build2_loc (loc, code, TREE_TYPE (org_x), op0, op1); - if (TREE_NO_WARNING (org_x) && warn_nonnull_compare) - TREE_NO_WARNING (x) = 1; + if (warn_nonnull_compare + && get_no_warning (org_x, OPT_Wnonnull_compare)) + set_no_warning (x, OPT_Wnonnull_compare); } else x = org_x; @@ -2709,7 +2711,7 @@ cp_fold (tree x) if (EXPR_P (x) && TREE_CODE (x) == code) { TREE_THIS_VOLATILE (x) = TREE_THIS_VOLATILE (org_x); - TREE_NO_WARNING (x) = TREE_NO_WARNING (org_x); + copy_no_warning (x, org_x); } if (!c.evaluation_restricted_p ()) diff --git a/gcc/cp/cp-ubsan.c b/gcc/cp/cp-ubsan.c index 3dabb6aa18a..bd38faf17f6 100644 --- a/gcc/cp/cp-ubsan.c +++ b/gcc/cp/cp-ubsan.c @@ -81,7 +81,7 @@ cp_ubsan_instrument_vptr (location_t loc, tree op, tree type, bool is_addr, build_zero_cst (TREE_TYPE (op))); /* This is a compiler generated comparison, don't emit e.g. -Wnonnull-compare warning for it. */ - TREE_NO_WARNING (cond) = 1; + set_no_warning (cond, OPT_Wnonnull_compare); vptr = build3_loc (loc, COND_EXPR, uint64_type_node, cond, vptr, build_int_cst (uint64_type_node, 0)); } diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 7fa6e8df52b..90beaccc1aa 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -605,8 +605,6 @@ ignore_overflows (tree expr, tree orig) tree cp_fold_convert (tree type, tree expr) { - bool nowarn = TREE_NO_WARNING (expr); - tree conv; if (TREE_TYPE (expr) == type) conv = expr; @@ -630,8 +628,8 @@ cp_fold_convert (tree type, tree expr) conv = ignore_overflows (conv, expr); } - if (nowarn && TREE_CODE (expr) == TREE_CODE (conv)) - TREE_NO_WARNING (conv) = nowarn; + if (TREE_CODE (expr) == TREE_CODE (conv)) + copy_no_warning (conv, expr); return conv; } @@ -1208,7 +1206,7 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain) /* The second part of a compound expr contains the value. */ tree op1 = TREE_OPERAND (expr,1); tree new_op1; - if (implicit != ICV_CAST && !TREE_NO_WARNING (expr)) + if (implicit != ICV_CAST && !get_no_warning (expr /* What warning? */)) new_op1 = convert_to_void (op1, ICV_RIGHT_OF_COMMA, complain); else new_op1 = convert_to_void (op1, ICV_CAST, complain); @@ -1394,7 +1392,7 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain) if (warn_unused_value && implicit != ICV_CAST && (complain & tf_warning) - && !TREE_NO_WARNING (expr) + && !get_no_warning (expr, OPT_Wunused_value) && !is_reference) warning_at (loc, OPT_Wunused_value, "value computed is not used"); expr = TREE_OPERAND (expr, 0); @@ -1578,7 +1576,7 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain) { if (implicit != ICV_CAST && warn_unused_value - && !TREE_NO_WARNING (expr) + && !get_no_warning (expr, OPT_Wunused_value) && !processing_template_decl && !cp_unevaluated_operand && (complain & tf_warning)) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 28052df9f45..b23d1eaeb3d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -839,7 +839,7 @@ wrapup_namespace_globals () && !TREE_PUBLIC (decl) && !DECL_ARTIFICIAL (decl) && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl) - && !TREE_NO_WARNING (decl)) + && !get_no_warning (decl, OPT_Wunused_function)) warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_function, "%qF declared % but never defined", decl); @@ -13851,10 +13851,7 @@ grokdeclarator (const cp_declarator *declarator, decl = build_decl (id_loc, FIELD_DECL, unqualified_id, type); DECL_NONADDRESSABLE_P (decl) = bitfield; if (bitfield && !unqualified_id) - { - TREE_NO_WARNING (decl) = 1; - DECL_PADDING_P (decl) = 1; - } + DECL_PADDING_P (decl) = 1; if (storage_class == sc_mutable) { @@ -17448,7 +17445,7 @@ finish_function (bool inline_p) /* Don't complain if we are declared noreturn. */ && !TREE_THIS_VOLATILE (fndecl) && !DECL_NAME (DECL_RESULT (fndecl)) - && !TREE_NO_WARNING (fndecl) + && !get_no_warning (fndecl, OPT_Wreturn_type) /* Structor return values (if any) are set by the compiler. */ && !DECL_CONSTRUCTOR_P (fndecl) && !DECL_DESTRUCTOR_P (fndecl) @@ -17476,7 +17473,7 @@ finish_function (bool inline_p) else if (warning_at (&richloc, OPT_Wreturn_type, "no return statement in function returning " "non-void")) - TREE_NO_WARNING (fndecl) = 1; + set_no_warning (fndecl, OPT_Wreturn_type); } /* Lambda closure members are implicitly constexpr if possible. */ @@ -17550,7 +17547,7 @@ finish_function (bool inline_p) && !DECL_READ_P (decl) && DECL_NAME (decl) && !DECL_ARTIFICIAL (decl) - && !TREE_NO_WARNING (decl) + && !get_no_warning (decl,OPT_Wunused_but_set_parameter) && !DECL_IN_SYSTEM_HEADER (decl) && TREE_TYPE (decl) != error_mark_node && !TYPE_REF_P (TREE_TYPE (decl)) @@ -18041,7 +18038,7 @@ require_deduced_type (tree decl, tsubst_flags_t complain) { if (undeduced_auto_decl (decl)) { - if (TREE_NO_WARNING (decl) && seen_error ()) + if (get_no_warning (decl) && seen_error ()) /* We probably already complained about deduction failure. */; else if (complain & tf_error) error ("use of %qD before deduction of %", decl); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 89f874a32cc..b939c884b95 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4529,7 +4529,7 @@ no_linkage_error (tree decl) || (errorcount + sorrycount > 0 && DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl) - && TREE_NO_WARNING (decl)))) + && get_no_warning (decl /* What warning? */)))) /* In C++11 it's ok if the decl is defined. */ return; @@ -5204,7 +5204,7 @@ c_parse_final_cleanups (void) && warning_at (DECL_SOURCE_LOCATION (decl), 0, "inline function %qD used but never defined", decl)) /* Avoid a duplicate warning from check_global_declaration. */ - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl, OPT_Wunused); } /* So must decls that use a type with no linkage. */ diff --git a/gcc/cp/except.c b/gcc/cp/except.c index cbafc09629b..19ea97ce19b 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -466,7 +466,8 @@ expand_end_catch_block (void) || DECL_DESTRUCTOR_P (current_function_decl))) { tree rethrow = build_throw (input_location, NULL_TREE); - TREE_NO_WARNING (rethrow) = true; + /* Disable all warnings for the generated rethrow statement. */ + set_no_warning (rethrow); finish_expr_stmt (rethrow); } } diff --git a/gcc/cp/init.c b/gcc/cp/init.c index a85f4d50750..52055f10cad 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3536,11 +3536,11 @@ build_new_1 (vec **placement, tree type, tree nelts, the arguments to the constructor call. */ { /* CLEANUP is compiler-generated, so no diagnostics. */ - TREE_NO_WARNING (cleanup) = true; + set_no_warning (cleanup); init_expr = build2 (TRY_CATCH_EXPR, void_type_node, init_expr, cleanup); /* Likewise, this try-catch is compiler-generated. */ - TREE_NO_WARNING (init_expr) = true; + set_no_warning (init_expr); } else /* Ack! First we allocate the memory. Then we set our sentry @@ -3562,7 +3562,7 @@ build_new_1 (vec **placement, tree type, tree nelts, sentry = TARGET_EXPR_SLOT (begin); /* CLEANUP is compiler-generated, so no diagnostics. */ - TREE_NO_WARNING (cleanup) = true; + set_no_warning (cleanup); TARGET_EXPR_CLEANUP (begin) = build3 (COND_EXPR, void_type_node, sentry, @@ -3576,7 +3576,7 @@ build_new_1 (vec **placement, tree type, tree nelts, build2 (COMPOUND_EXPR, void_type_node, init_expr, end)); /* Likewise, this is compiler-generated. */ - TREE_NO_WARNING (init_expr) = true; + set_no_warning (init_expr); } } } @@ -3823,7 +3823,7 @@ build_new (location_t loc, vec **placement, tree type, /* Wrap it in a NOP_EXPR so warn_if_unused_value doesn't complain. */ rval = build1_loc (loc, NOP_EXPR, TREE_TYPE (rval), rval); - TREE_NO_WARNING (rval) = 1; + set_no_warning (rval, OPT_Wunused_value); return rval; } @@ -3995,7 +3995,7 @@ build_vec_delete_1 (location_t loc, tree base, tree maxindex, tree type, fold_convert (TREE_TYPE (base), nullptr_node)); /* This is a compiler generated comparison, don't emit e.g. -Wnonnull-compare warning for it. */ - TREE_NO_WARNING (cond) = 1; + set_no_warning (cond, OPT_Wnonnull_compare); body = build3_loc (loc, COND_EXPR, void_type_node, cond, body, integer_zero_node); COND_EXPR_IS_VEC_DELETE (body) = true; @@ -4657,7 +4657,7 @@ build_vec_init (tree base, tree maxindex, tree init, atype = build_pointer_type (atype); stmt_expr = build1 (NOP_EXPR, atype, stmt_expr); stmt_expr = cp_build_fold_indirect_ref (stmt_expr); - TREE_NO_WARNING (stmt_expr) = 1; + set_no_warning (stmt_expr /* What warning? */); } return stmt_expr; @@ -4924,7 +4924,7 @@ build_delete (location_t loc, tree otype, tree addr, /* This is a compiler generated comparison, don't emit e.g. -Wnonnull-compare warning for it. */ else if (TREE_CODE (ifexp) == NE_EXPR) - TREE_NO_WARNING (ifexp) = 1; + set_no_warning (ifexp, OPT_Wnonnull_compare); if (!integer_nonzerop (ifexp)) expr = build3 (COND_EXPR, void_type_node, ifexp, expr, void_node); diff --git a/gcc/cp/method.c b/gcc/cp/method.c index dd745237f22..9942a73ba6e 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -3284,7 +3284,7 @@ defaultable_fn_check (tree fn) /* Avoid do_warn_unused_parameter warnings. */ for (tree p = FUNCTION_FIRST_USER_PARM (fn); p; p = DECL_CHAIN (p)) if (DECL_NAME (p)) - TREE_NO_WARNING (p) = 1; + set_no_warning (p, OPT_Wunused_parameter); if (current_class_type && TYPE_BEING_DEFINED (current_class_type)) /* Defer checking. */; diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index bc0505df502..32dced21f5c 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1,3 +1,4 @@ + /* -*- C++ -*- Parser. Copyright (C) 2000-2021 Free Software Foundation, Inc. Written by Mark Mitchell . @@ -5322,7 +5323,7 @@ cp_parser_fold_expression (cp_parser *parser, tree expr1) /* The operands of a fold-expression are cast-expressions, so binary or conditional expressions are not allowed. We check this here to avoid tentative parsing. */ - if (EXPR_P (expr1) && TREE_NO_WARNING (expr1)) + if (EXPR_P (expr1) && get_no_warning (expr1, OPT_Wparentheses)) /* OK, the expression was parenthesized. */; else if (is_binary_op (TREE_CODE (expr1))) error_at (location_of (expr1), @@ -5603,7 +5604,10 @@ cp_parser_primary_expression (cp_parser *parser, /* Consume the `)'. */ token = cp_lexer_peek_token (parser->lexer); location_t close_paren_loc = token->location; + bool no_wparens = get_no_warning (expr, OPT_Wparentheses); expr.set_range (open_paren_loc, close_paren_loc); + if (no_wparens) + set_no_warning (expr, OPT_Wparentheses); if (!parens.require_close (parser) && !cp_parser_uncommitted_to_tentative_parse_p (parser)) cp_parser_skip_to_end_of_statement (parser); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cbd2f3dc338..170cb4eead0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10942,9 +10942,9 @@ push_tinst_level_loc (tree tldcl, tree targs, location_t loc) constant expressions. */ if (!targs && limit_bad_template_recursion (tldcl)) { - /* Avoid no_linkage_errors and unused function warnings for this - decl. */ - TREE_NO_WARNING (tldcl) = 1; + /* Avoid no_linkage_errors and unused function (and all other) + warnings for this decl. */ + set_no_warning (tldcl); return false; } @@ -17087,7 +17087,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) tree op1 = tsubst_copy (TREE_OPERAND (t, 1), args, complain, in_decl); tree op2 = tsubst_copy (TREE_OPERAND (t, 2), args, complain, in_decl); r = build_nt (code, op0, op1, op2); - TREE_NO_WARNING (r) = TREE_NO_WARNING (t); + copy_no_warning (r, t); return r; } @@ -19169,8 +19169,7 @@ tsubst_omp_udr (tree t, tree args, tsubst_flags_t complain, tree in_decl) block = finish_omp_structured_block (block); block = maybe_cleanup_point_expr_void (block); add_decl_expr (omp_out); - if (TREE_NO_WARNING (DECL_EXPR_DECL (stmts[0]))) - TREE_NO_WARNING (omp_out) = 1; + copy_no_warning (omp_out, DECL_EXPR_DECL (stmts[0])); add_decl_expr (omp_in); finish_expr_stmt (block); } @@ -19846,17 +19845,17 @@ tsubst_copy_and_build (tree t, tree r = build_x_binary_op (input_location, TREE_CODE (t), op0, - (TREE_NO_WARNING (TREE_OPERAND (t, 0)) + (get_no_warning (TREE_OPERAND (t, 0)) ? ERROR_MARK : TREE_CODE (TREE_OPERAND (t, 0))), op1, - (TREE_NO_WARNING (TREE_OPERAND (t, 1)) + (get_no_warning (TREE_OPERAND (t, 1)) ? ERROR_MARK : TREE_CODE (TREE_OPERAND (t, 1))), /*overload=*/NULL, complain|decltype_flag); - if (EXPR_P (r) && TREE_NO_WARNING (t)) - TREE_NO_WARNING (r) = TREE_NO_WARNING (t); + if (EXPR_P (r)) + copy_no_warning (r, t); RETURN (r); } @@ -19992,8 +19991,8 @@ tsubst_copy_and_build (tree t, set and must be copied. In the latter case, build_x_modify_expr sets it and it must not be reset here. */ - if (TREE_NO_WARNING (t)) - TREE_NO_WARNING (r) = TREE_NO_WARNING (t); + if (get_no_warning (t, OPT_Wparentheses)) + set_no_warning (r, OPT_Wparentheses); RETURN (r); } diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 82eaa286514..328067bcb6c 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -536,14 +536,14 @@ build_if_nonnull (tree test, tree result, tsubst_flags_t complain) /* This is a compiler generated comparison, don't emit e.g. -Wnonnull-compare warning for it. */ - TREE_NO_WARNING (cond) = 1; + set_no_warning (cond, OPT_Wnonnull); null_ptr = cp_convert (TREE_TYPE (result), nullptr_node, complain); cond = build3 (COND_EXPR, TREE_TYPE (result), cond, result, null_ptr); /* Likewise, don't emit -Wnonnull for using the result to call a member function. */ - TREE_NO_WARNING (cond) = 1; + set_no_warning (cond, OPT_Wnonnull); return cond; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 0d590c318fb..9454f094374 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -836,12 +836,12 @@ maybe_convert_cond (tree cond) cond = convert_from_reference (cond); if (TREE_CODE (cond) == MODIFY_EXPR - && !TREE_NO_WARNING (cond) && warn_parentheses + && !get_no_warning (cond, OPT_Wparentheses) && warning_at (cp_expr_loc_or_input_loc (cond), OPT_Wparentheses, "suggest parentheses around " "assignment used as truth value")) - TREE_NO_WARNING (cond) = 1; + set_no_warning (cond, OPT_Wparentheses); return condition_conversion (cond); } @@ -1144,7 +1144,7 @@ finish_return_stmt (tree expr) { /* Suppress -Wreturn-type for this function. */ if (warn_return_type) - TREE_NO_WARNING (current_function_decl) = true; + set_no_warning (current_function_decl, OPT_Wreturn_type); return error_mark_node; } @@ -1166,7 +1166,8 @@ finish_return_stmt (tree expr) } r = build_stmt (input_location, RETURN_EXPR, expr); - TREE_NO_WARNING (r) |= no_warning; + if (no_warning) + set_no_warning (r, OPT_Wreturn_type); r = maybe_cleanup_point_expr_void (r); r = add_stmt (r); @@ -2052,7 +2053,7 @@ finish_parenthesized_expr (cp_expr expr) { if (EXPR_P (expr)) /* This inhibits warnings in c_common_truthvalue_conversion. */ - TREE_NO_WARNING (expr) = 1; + set_no_warning (expr, OPT_Wparentheses); if (TREE_CODE (expr) == OFFSET_REF || TREE_CODE (expr) == SCOPE_REF) @@ -5911,12 +5912,12 @@ cp_check_omp_declare_reduction (tree udr) { gcc_assert (TREE_CODE (data.stmts[0]) == DECL_EXPR && TREE_CODE (data.stmts[1]) == DECL_EXPR); - if (TREE_NO_WARNING (DECL_EXPR_DECL (data.stmts[0]))) + if (get_no_warning (DECL_EXPR_DECL (data.stmts[0]) /* What warning? */)) return true; data.combiner_p = true; if (cp_walk_tree (&data.stmts[2], cp_check_omp_declare_reduction_r, &data, NULL)) - TREE_NO_WARNING (DECL_EXPR_DECL (data.stmts[0])) = 1; + set_no_warning (DECL_EXPR_DECL (data.stmts[0]) /* What warning? */); } if (i >= 6) { @@ -5927,7 +5928,7 @@ cp_check_omp_declare_reduction (tree udr) &data, NULL) || cp_walk_tree (&DECL_INITIAL (DECL_EXPR_DECL (data.stmts[3])), cp_check_omp_declare_reduction_r, &data, NULL)) - TREE_NO_WARNING (DECL_EXPR_DECL (data.stmts[0])) = 1; + set_no_warning (DECL_EXPR_DECL (data.stmts[0]) /* Wat warning? */); if (i == 7) gcc_assert (TREE_CODE (data.stmts[6]) == DECL_EXPR); } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 72f498f4b3b..c0c0dd128ce 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1126,7 +1126,7 @@ build_cplus_array_type (tree elt_type, tree index_type, int dependent) /* Avoid spurious warnings with VLAs (c++/54583). */ if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t))) - TREE_NO_WARNING (TYPE_SIZE (t)) = 1; + set_no_warning (TYPE_SIZE (t), OPT_Wunused); /* Push these needs up to the ARRAY_TYPE so that initialization takes place more easily. */ diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 703ddd3cc7a..3fe8b0cc7a9 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3316,10 +3316,7 @@ build_ptrmemfunc_access_expr (tree ptrmem, tree member_name) member = DECL_CHAIN (member)) if (DECL_NAME (member) == member_name) break; - tree res = build_simple_component_ref (ptrmem, member); - - TREE_NO_WARNING (res) = 1; - return res; + return build_simple_component_ref (ptrmem, member); } /* Given an expression PTR for a pointer, return an expression @@ -3433,7 +3430,7 @@ cp_build_indirect_ref_1 (location_t loc, tree ptr, ref_operator errorstring, if (warn_strict_aliasing > 2 && cp_strict_aliasing_warning (EXPR_LOCATION (ptr), type, TREE_OPERAND (ptr, 0))) - TREE_NO_WARNING (ptr) = 1; + set_no_warning (ptr, OPT_Wstrict_aliasing); } if (VOID_TYPE_P (t)) @@ -4058,7 +4055,7 @@ cp_build_function_call_vec (tree function, vec **params, { tree c = extract_call_expr (ret); if (TREE_CODE (c) == CALL_EXPR) - TREE_NO_WARNING (c) = 1; + set_no_warning (c, OPT_Wnonnull); } if (allocated != NULL) @@ -4440,14 +4437,14 @@ warn_for_null_address (location_t location, tree op, tsubst_flags_t complain) if (!warn_address || (complain & tf_warning) == 0 || c_inhibit_evaluation_warnings != 0 - || TREE_NO_WARNING (op)) + || get_no_warning (op, OPT_Waddress)) return; tree cop = fold_for_warn (op); if (TREE_CODE (cop) == ADDR_EXPR && decl_with_nonnull_addr_p (TREE_OPERAND (cop, 0)) - && !TREE_NO_WARNING (cop)) + && !get_no_warning (cop, OPT_Waddress)) warning_at (location, OPT_Waddress, "the address of %qD will never " "be NULL", TREE_OPERAND (cop, 0)); @@ -4868,7 +4865,7 @@ cp_build_binary_op (const op_location_t &location, else if (TREE_CODE (type0) == ARRAY_TYPE && !char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type0))) /* Set by finish_parenthesized_expr. */ - && !TREE_NO_WARNING (op1) + && !get_no_warning (op1, OPT_Wsizeof_array_div) && (complain & tf_warning)) maybe_warn_sizeof_array_div (location, first_arg, type0, op1, non_reference (type1)); @@ -5287,7 +5284,7 @@ cp_build_binary_op (const op_location_t &location, pfn0 = cp_fully_fold (pfn0); /* Avoid -Waddress warnings (c++/64877). */ if (TREE_CODE (pfn0) == ADDR_EXPR) - TREE_NO_WARNING (pfn0) = 1; + set_no_warning (pfn0, OPT_Waddress); pfn1 = pfn_from_ptrmemfunc (op1); pfn1 = cp_fully_fold (pfn1); delta0 = delta_from_ptrmemfunc (op0); @@ -7016,7 +7013,7 @@ unary_complex_lvalue (enum tree_code code, tree arg) tf_warning_or_error); arg = build2 (COMPOUND_EXPR, TREE_TYPE (real_result), arg, real_result); - TREE_NO_WARNING (arg) = 1; + set_no_warning (arg); return arg; } @@ -8927,7 +8924,7 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode, TREE_SIDE_EFFECTS (result) = 1; if (!plain_assign) - TREE_NO_WARNING (result) = 1; + set_no_warning (result, OPT_Wparentheses); ret: if (preeval) @@ -8971,7 +8968,7 @@ build_x_modify_expr (location_t loc, tree lhs, enum tree_code modifycode, { if (rval == error_mark_node) return rval; - TREE_NO_WARNING (rval) = 1; + set_no_warning (rval /* What warning? */); if (processing_template_decl) { if (overload != NULL_TREE) @@ -9578,13 +9575,13 @@ convert_for_assignment (tree type, tree rhs, if (warn_parentheses && TREE_CODE (type) == BOOLEAN_TYPE && TREE_CODE (rhs) == MODIFY_EXPR - && !TREE_NO_WARNING (rhs) + && !get_no_warning (rhs, OPT_Wparentheses) && TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE && (complain & tf_warning) && warning_at (rhs_loc, OPT_Wparentheses, "suggest parentheses around assignment used as " "truth value")) - TREE_NO_WARNING (rhs) = 1; + set_no_warning (rhs, OPT_Wparentheses); if (complain & tf_warning) warn_for_address_or_pointer_of_packed_member (type, rhs); From patchwork Mon May 24 22:12:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482986 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=snKxxDJi; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fps0b2YRKz9s24 for ; Tue, 25 May 2021 08:13:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DEEA93853836; Mon, 24 May 2021 22:12:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DEEA93853836 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621894379; bh=EJY+LJkUuK8Jfvby263hIX1KDQDIwsNL4xowlIOgcus=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=snKxxDJiz/8RmU+7liBEbVLdT8HgAuzfq89s8Ei5NrwsyXMpOmpUbqiSCvz9jGiEn z8bs0ZHHJ7XyoE+gsPKpu/hFVNR+gCD12T8ngajWhDdEIQLdEW9SRiOcA1QL7TpLfg 49HEy0q5ZXBmzyKbQjJYl5uPRIF6h5jqpQKwNifA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 2507A383581E for ; Mon, 24 May 2021 22:12:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2507A383581E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-560-8ipOIFrNMpGwuzmLQnk-vg-1; Mon, 24 May 2021 18:12:44 -0400 X-MC-Unique: 8ipOIFrNMpGwuzmLQnk-vg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DFB12107ACCD for ; Mon, 24 May 2021 22:12:43 +0000 (UTC) Received: from [10.3.114.34] (ovpn-114-34.phx2.redhat.com [10.3.114.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 983A7687E2 for ; Mon, 24 May 2021 22:12:43 +0000 (UTC) Subject: [PATCH 6/11] use xxx_no_warning APIs in Fortran To: gcc-patches References: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Message-ID: <172c301f-6983-07a8-9a8f-0f25f644e555@redhat.com> Date: Mon, 24 May 2021 16:12:43 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The attached patch replaces the uses of TREE_NO_WARNING in the Fortran front end. I don't know the Fortran front end and I made no effort to try to find the right warning options in the calls to set/get_no_warning. Add support for per-location warning groups. gcc/fortran/ChangeLog: * trans-array.c (trans_array_constructor): Replace direct uses of TREE_NO_WARNING with get_no_warning, and set_no_warning. * trans-decl.c (gfc_build_qualified_array): Same. (gfc_build_dummy_array_decl): Same. (generate_local_decl): Same. (gfc_generate_function_code): Same. * trans-openmp.c (gfc_omp_clause_default_ctor): Same. (gfc_omp_clause_copy_ctor): Same. * trans-types.c (get_dtype_type_node): Same. (gfc_get_desc_dim_type): Same. (gfc_get_array_descriptor_base): Same. (gfc_get_caf_vector_type): Same. (gfc_get_caf_reference_type): Same. * trans.c (gfc_create_var_np): Same. diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 6d38ea78273..30f9138b5cb 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -2755,7 +2755,7 @@ trans_array_constructor (gfc_ss * ss, locus * where) desc = ss_info->data.array.descriptor; offset = gfc_index_zero_node; offsetvar = gfc_create_var_np (gfc_array_index_type, "offset"); - TREE_NO_WARNING (offsetvar) = 1; + set_no_warning (offsetvar); TREE_USED (offsetvar) = 0; gfc_trans_array_constructor_value (&outer_loop->pre, type, desc, c, &offset, &offsetvar, dynamic); diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 406b4aeb1d4..81579849fe3 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1039,7 +1039,7 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym) if (GFC_TYPE_ARRAY_LBOUND (type, dim) == NULL_TREE) { GFC_TYPE_ARRAY_LBOUND (type, dim) = create_index_var ("lbound", nest); - TREE_NO_WARNING (GFC_TYPE_ARRAY_LBOUND (type, dim)) = 1; + set_no_warning (GFC_TYPE_ARRAY_LBOUND (type, dim)); } /* Don't try to use the unknown bound for assumed shape arrays. */ if (GFC_TYPE_ARRAY_UBOUND (type, dim) == NULL_TREE @@ -1047,13 +1047,13 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym) || dim < GFC_TYPE_ARRAY_RANK (type) - 1)) { GFC_TYPE_ARRAY_UBOUND (type, dim) = create_index_var ("ubound", nest); - TREE_NO_WARNING (GFC_TYPE_ARRAY_UBOUND (type, dim)) = 1; + set_no_warning (GFC_TYPE_ARRAY_UBOUND (type, dim)); } if (GFC_TYPE_ARRAY_STRIDE (type, dim) == NULL_TREE) { GFC_TYPE_ARRAY_STRIDE (type, dim) = create_index_var ("stride", nest); - TREE_NO_WARNING (GFC_TYPE_ARRAY_STRIDE (type, dim)) = 1; + set_no_warning (GFC_TYPE_ARRAY_STRIDE (type, dim)); } } for (dim = GFC_TYPE_ARRAY_RANK (type); @@ -1062,21 +1062,21 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym) if (GFC_TYPE_ARRAY_LBOUND (type, dim) == NULL_TREE) { GFC_TYPE_ARRAY_LBOUND (type, dim) = create_index_var ("lbound", nest); - TREE_NO_WARNING (GFC_TYPE_ARRAY_LBOUND (type, dim)) = 1; + set_no_warning (GFC_TYPE_ARRAY_LBOUND (type, dim)); } /* Don't try to use the unknown ubound for the last coarray dimension. */ if (GFC_TYPE_ARRAY_UBOUND (type, dim) == NULL_TREE && dim < GFC_TYPE_ARRAY_RANK (type) + GFC_TYPE_ARRAY_CORANK (type) - 1) { GFC_TYPE_ARRAY_UBOUND (type, dim) = create_index_var ("ubound", nest); - TREE_NO_WARNING (GFC_TYPE_ARRAY_UBOUND (type, dim)) = 1; + set_no_warning (GFC_TYPE_ARRAY_UBOUND (type, dim)); } } if (GFC_TYPE_ARRAY_OFFSET (type) == NULL_TREE) { GFC_TYPE_ARRAY_OFFSET (type) = gfc_create_var_np (gfc_array_index_type, "offset"); - TREE_NO_WARNING (GFC_TYPE_ARRAY_OFFSET (type)) = 1; + set_no_warning (GFC_TYPE_ARRAY_OFFSET (type)); if (nest) gfc_add_decl_to_parent_function (GFC_TYPE_ARRAY_OFFSET (type)); @@ -1088,7 +1088,7 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym) && as->type != AS_ASSUMED_SIZE) { GFC_TYPE_ARRAY_SIZE (type) = create_index_var ("size", nest); - TREE_NO_WARNING (GFC_TYPE_ARRAY_SIZE (type)) = 1; + set_no_warning (GFC_TYPE_ARRAY_SIZE (type)); } if (POINTER_TYPE_P (type)) @@ -1293,7 +1293,7 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy) /* Avoid uninitialized warnings for optional dummy arguments. */ if (sym->attr.optional) - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl); /* We should never get deferred shape arrays here. We used to because of frontend bugs. */ @@ -5974,7 +5974,7 @@ generate_local_decl (gfc_symbol * sym) "does not have a default initializer", sym->name, &sym->declared_at); if (sym->backend_decl != NULL_TREE) - TREE_NO_WARNING(sym->backend_decl) = 1; + set_no_warning (sym->backend_decl); } else if (warn_unused_dummy_argument) { @@ -5984,7 +5984,7 @@ generate_local_decl (gfc_symbol * sym) &sym->declared_at); if (sym->backend_decl != NULL_TREE) - TREE_NO_WARNING(sym->backend_decl) = 1; + set_no_warning (sym->backend_decl); } } @@ -6000,7 +6000,7 @@ generate_local_decl (gfc_symbol * sym) "explicitly imported at %L", sym->name, &sym->declared_at); if (sym->backend_decl != NULL_TREE) - TREE_NO_WARNING(sym->backend_decl) = 1; + set_no_warning (sym->backend_decl); } else if (!sym->attr.use_assoc) { @@ -6018,7 +6018,7 @@ generate_local_decl (gfc_symbol * sym) "Unused variable %qs declared at %L", sym->name, &sym->declared_at); if (sym->backend_decl != NULL_TREE) - TREE_NO_WARNING(sym->backend_decl) = 1; + set_no_warning (sym->backend_decl); } } @@ -6133,7 +6133,7 @@ generate_local_decl (gfc_symbol * sym) /* Silence bogus "unused parameter" warnings from the middle end. */ if (sym->backend_decl != NULL_TREE) - TREE_NO_WARNING (sym->backend_decl) = 1; + set_no_warning (sym->backend_decl); } } @@ -6964,7 +6964,7 @@ gfc_generate_function_code (gfc_namespace * ns) "Return value of function %qs at %L not set", sym->name, &sym->declared_at); if (warn_return_type > 0) - TREE_NO_WARNING(sym->backend_decl) = 1; + set_no_warning (sym->backend_decl); } if (result != NULL_TREE) gfc_add_expr_to_block (&body, gfc_generate_return ()); diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 5666cd68c7e..f1d823e9f74 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -729,7 +729,7 @@ gfc_omp_clause_default_ctor (tree clause, tree decl, tree outer) else_b)); /* Avoid -W*uninitialized warnings. */ if (DECL_P (decl)) - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl, OPT_Wuninitialized); } else gfc_add_expr_to_block (&block, then_b); @@ -838,7 +838,7 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree src) void_type_node, cond, then_b, else_b)); /* Avoid -W*uninitialized warnings. */ if (DECL_P (dest)) - TREE_NO_WARNING (dest) = 1; + set_no_warning (dest, OPT_Wuninitialized); return gfc_finish_block (&block); } diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 9f21b3ee780..d859d37a03c 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -150,23 +150,23 @@ tree get_dtype_type_node (void) field = gfc_add_field_to_struct_1 (dtype_node, get_identifier ("elem_len"), size_type_node, &dtype_chain); - TREE_NO_WARNING (field) = 1; + set_no_warning (field); field = gfc_add_field_to_struct_1 (dtype_node, get_identifier ("version"), integer_type_node, &dtype_chain); - TREE_NO_WARNING (field) = 1; + set_no_warning (field); field = gfc_add_field_to_struct_1 (dtype_node, get_identifier ("rank"), signed_char_type_node, &dtype_chain); - TREE_NO_WARNING (field) = 1; + set_no_warning (field); field = gfc_add_field_to_struct_1 (dtype_node, get_identifier ("type"), signed_char_type_node, &dtype_chain); - TREE_NO_WARNING (field) = 1; + set_no_warning (field); field = gfc_add_field_to_struct_1 (dtype_node, get_identifier ("attribute"), short_integer_type_node, &dtype_chain); - TREE_NO_WARNING (field) = 1; + set_no_warning (field); gfc_finish_type (dtype_node); TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (dtype_node)) = 1; dtype_type_node = dtype_node; @@ -1453,17 +1453,17 @@ gfc_get_desc_dim_type (void) decl = gfc_add_field_to_struct_1 (type, get_identifier ("stride"), gfc_array_index_type, &chain); - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl); decl = gfc_add_field_to_struct_1 (type, get_identifier ("lbound"), gfc_array_index_type, &chain); - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl); decl = gfc_add_field_to_struct_1 (type, get_identifier ("ubound"), gfc_array_index_type, &chain); - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl); /* Finish off the type. */ gfc_finish_type (type); @@ -1831,19 +1831,19 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted) decl = gfc_add_field_to_struct_1 (fat_type, get_identifier ("offset"), gfc_array_index_type, &chain); - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl); /* Add the dtype component. */ decl = gfc_add_field_to_struct_1 (fat_type, get_identifier ("dtype"), get_dtype_type_node (), &chain); - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl); /* Add the span component. */ decl = gfc_add_field_to_struct_1 (fat_type, get_identifier ("span"), gfc_array_index_type, &chain); - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl); /* Build the array type for the stride and bound components. */ if (dimen + codimen > 0) @@ -1856,7 +1856,7 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted) decl = gfc_add_field_to_struct_1 (fat_type, get_identifier ("dim"), arraytype, &chain); - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl); } if (flag_coarray == GFC_FCOARRAY_LIB) @@ -1864,7 +1864,7 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted) decl = gfc_add_field_to_struct_1 (fat_type, get_identifier ("token"), prvoid_type_node, &chain); - TREE_NO_WARNING (decl) = 1; + set_no_warning (decl); } /* Finish off the type. */ @@ -2856,7 +2856,7 @@ copy_derived_types: token = gfc_find_component (derived, caf_name, true, true, NULL); gcc_assert (token); c->caf_token = token->backend_decl; - TREE_NO_WARNING (c->caf_token) = 1; + set_no_warning (c->caf_token); } } @@ -3521,11 +3521,11 @@ gfc_get_caf_vector_type (int dim) tmp = gfc_add_field_to_struct_1 (vect_struct_type, get_identifier ("vector"), pvoid_type_node, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (vect_struct_type, get_identifier ("kind"), integer_type_node, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); gfc_finish_type (vect_struct_type); chain = 0; @@ -3533,34 +3533,34 @@ gfc_get_caf_vector_type (int dim) tmp = gfc_add_field_to_struct_1 (triplet_struct_type, get_identifier ("lower_bound"), gfc_array_index_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (triplet_struct_type, get_identifier ("upper_bound"), gfc_array_index_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (triplet_struct_type, get_identifier ("stride"), gfc_array_index_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); gfc_finish_type (triplet_struct_type); chain = 0; union_type = make_node (UNION_TYPE); tmp = gfc_add_field_to_struct_1 (union_type, get_identifier ("v"), vect_struct_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (union_type, get_identifier ("triplet"), triplet_struct_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); gfc_finish_type (union_type); chain = 0; vec_type = make_node (RECORD_TYPE); tmp = gfc_add_field_to_struct_1 (vec_type, get_identifier ("nvec"), size_type_node, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (vec_type, get_identifier ("u"), union_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); gfc_finish_type (vec_type); TYPE_NAME (vec_type) = get_identifier ("caf_vector_t"); } @@ -3587,11 +3587,11 @@ gfc_get_caf_reference_type () tmp = gfc_add_field_to_struct_1 (c_struct_type, get_identifier ("offset"), gfc_array_index_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (c_struct_type, get_identifier ("caf_token_offset"), gfc_array_index_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); gfc_finish_type (c_struct_type); chain = 0; @@ -3599,15 +3599,15 @@ gfc_get_caf_reference_type () tmp = gfc_add_field_to_struct_1 (s_struct_type, get_identifier ("start"), gfc_array_index_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (s_struct_type, get_identifier ("end"), gfc_array_index_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (s_struct_type, get_identifier ("stride"), gfc_array_index_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); gfc_finish_type (s_struct_type); chain = 0; @@ -3615,25 +3615,25 @@ gfc_get_caf_reference_type () tmp = gfc_add_field_to_struct_1 (v_struct_type, get_identifier ("vector"), pvoid_type_node, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (v_struct_type, get_identifier ("nvec"), size_type_node, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (v_struct_type, get_identifier ("kind"), integer_type_node, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); gfc_finish_type (v_struct_type); chain = 0; union_type = make_node (UNION_TYPE); tmp = gfc_add_field_to_struct_1 (union_type, get_identifier ("s"), s_struct_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (union_type, get_identifier ("v"), v_struct_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); gfc_finish_type (union_type); tmp = build_range_type (gfc_array_index_type, gfc_index_zero_node, @@ -3648,40 +3648,40 @@ gfc_get_caf_reference_type () gfc_index_zero_node, gfc_rank_cst[GFC_MAX_DIMENSIONS - 1])), &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (a_struct_type, get_identifier ("static_array_type"), integer_type_node, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (a_struct_type, get_identifier ("dim"), dim_union_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); gfc_finish_type (a_struct_type); chain = 0; u_union_type = make_node (UNION_TYPE); tmp = gfc_add_field_to_struct_1 (u_union_type, get_identifier ("c"), c_struct_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (u_union_type, get_identifier ("a"), a_struct_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); gfc_finish_type (u_union_type); chain = 0; reference_type = make_node (RECORD_TYPE); tmp = gfc_add_field_to_struct_1 (reference_type, get_identifier ("next"), build_pointer_type (reference_type), &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (reference_type, get_identifier ("type"), integer_type_node, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (reference_type, get_identifier ("item_size"), size_type_node, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); tmp = gfc_add_field_to_struct_1 (reference_type, get_identifier ("u"), u_union_type, &chain); - TREE_NO_WARNING (tmp) = 1; + set_no_warning (tmp); gfc_finish_type (reference_type); TYPE_NAME (reference_type) = get_identifier ("caf_reference_t"); diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index 9f296bd8c03..f1696924345 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -129,7 +129,7 @@ gfc_create_var_np (tree type, const char *prefix) /* No warnings for anonymous variables. */ if (prefix == NULL) - TREE_NO_WARNING (t) = 1; + set_no_warning (t); return t; } From patchwork Mon May 24 22:13:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=CeN9EoCT; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fps191bBFz9s24 for ; Tue, 25 May 2021 08:13:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A89AA383541E; Mon, 24 May 2021 22:13:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A89AA383541E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621894410; bh=KhbFc4fcosX1qHt+Ky9Nij8nR1YLca4TRfD5Z3JcYi4=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=CeN9EoCT7Y9qSYf0BfY1tLK8pFTbbpd2Hl6wZ0NUUX+f8uStbQSJcZxlH7gNZ36Mm ZEo4CyupKlQqIRf4JSrIi/XBTdxpVKO97m2Wmqp5lw+M2iqyuMYj0vXRbKBLdf+KRW gugH0p76uQ+29XS3PeOCuBnfOlWq0neL7Wdux+JE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id D2DBB3853836 for ; Mon, 24 May 2021 22:13:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D2DBB3853836 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-280-5VZX6OMBNXuNiI9egi8ytw-1; Mon, 24 May 2021 18:13:26 -0400 X-MC-Unique: 5VZX6OMBNXuNiI9egi8ytw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7B63F189C440 for ; Mon, 24 May 2021 22:13:25 +0000 (UTC) Received: from [10.3.114.34] (ovpn-114-34.phx2.redhat.com [10.3.114.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4360F1ACD3 for ; Mon, 24 May 2021 22:13:25 +0000 (UTC) Subject: [PATCH 7/11] use xxx_no_warning APIs in Fortran To: gcc-patches References: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Message-ID: <4f69735d-00a0-76a0-797a-fb4acf57d13c@redhat.com> Date: Mon, 24 May 2021 16:13:25 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The attached patch replaces the uses of TREE_NO_WARNING in the LTO front end. The streaming support doesn't extend to multiple bits yet. I plan to do that in a follow-up change. Add support for per-location warning groups. gcc/lto/ChangeLog: * gimple-streamer-out.c (output_gimple_stmt): Same. * lto-common.c (compare_tree_sccs_1): Expand use of TREE_NO_WARNING. * lto-streamer-out.c (hash_tree): Same. * tree-streamer-in.c (unpack_ts_base_value_fields): Same. * tree-streamer-out.c (pack_ts_base_value_fields): Same. diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c index fcbf92300d4..ae382665218 100644 --- a/gcc/gimple-streamer-out.c +++ b/gcc/gimple-streamer-out.c @@ -73,7 +73,7 @@ output_gimple_stmt (struct output_block *ob, struct function *fn, gimple *stmt) /* Emit the tuple header. */ bp = bitpack_create (ob->main_stream); bp_pack_var_len_unsigned (&bp, gimple_num_ops (stmt)); - bp_pack_value (&bp, gimple_no_warning_p (stmt), 1); + bp_pack_value (&bp, get_no_warning (stmt), 1); if (is_gimple_assign (stmt)) bp_pack_value (&bp, gimple_assign_nontemporal_move_p ( diff --git a/gcc/lto/lto-common.c b/gcc/lto/lto-common.c index 02d16f49c11..4f78c90effb 100644 --- a/gcc/lto/lto-common.c +++ b/gcc/lto/lto-common.c @@ -1110,8 +1110,8 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map) compare_values (TYPE_UNSIGNED); if (TYPE_P (t1)) compare_values (TYPE_ARTIFICIAL); - else - compare_values (TREE_NO_WARNING); + else if (t1->base.nowarning_flag != t2->base.nowarning_flag) + return false; compare_values (TREE_NOTHROW); compare_values (TREE_STATIC); if (code != TREE_BINFO) diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index a26d4885800..7fecb958efa 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -1207,7 +1207,7 @@ hash_tree (struct streamer_tree_cache_d *cache, hash_map *map, if (TYPE_P (t)) hstate.add_flag (TYPE_ARTIFICIAL (t)); else - hstate.add_flag (TREE_NO_WARNING (t)); + hstate.add_flag (get_no_warning (t)); hstate.add_flag (TREE_NOTHROW (t)); hstate.add_flag (TREE_STATIC (t)); hstate.add_flag (TREE_PROTECTED (t)); diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c index 984b1e269cf..fab7c678dae 100644 --- a/gcc/tree-streamer-in.c +++ b/gcc/tree-streamer-in.c @@ -131,7 +131,8 @@ unpack_ts_base_value_fields (struct bitpack_d *bp, tree expr) if (TYPE_P (expr)) TYPE_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1); else - TREE_NO_WARNING (expr) = (unsigned) bp_unpack_value (bp, 1); + /* FIXME: set all warning bits. */ + set_no_warning (expr, (unsigned) bp_unpack_value (bp, 1)); TREE_NOTHROW (expr) = (unsigned) bp_unpack_value (bp, 1); TREE_STATIC (expr) = (unsigned) bp_unpack_value (bp, 1); if (TREE_CODE (expr) != TREE_BINFO) diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c index 1a43534d117..d81ff60bd68 100644 --- a/gcc/tree-streamer-out.c +++ b/gcc/tree-streamer-out.c @@ -104,7 +104,8 @@ pack_ts_base_value_fields (struct bitpack_d *bp, tree expr) if (TYPE_P (expr)) bp_pack_value (bp, TYPE_ARTIFICIAL (expr), 1); else - bp_pack_value (bp, TREE_NO_WARNING (expr), 1); + /* FIXME: pack all warning bits. */ + bp_pack_value (bp, get_no_warning (expr), 1); bp_pack_value (bp, TREE_NOTHROW (expr), 1); bp_pack_value (bp, TREE_STATIC (expr), 1); if (TREE_CODE (expr) != TREE_BINFO) From patchwork Mon May 24 22:14:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482988 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=QBDq7U2n; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fps225hGJz9s24 for ; Tue, 25 May 2021 08:14:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6338A383541E; Mon, 24 May 2021 22:14:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6338A383541E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621894456; bh=UqQDNfBdN+8DAAGLurssyVCqT/1cM/9HIAifN4bLhmo=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=QBDq7U2nwc4bGa7uH5bgA9zD+vI7RMPi97ea8/YePNhiaYf7INJzZUNn9+eRLN9iX WYspUxNftgHcK2qwUIn+9pcNBYVBXDddkl6Qeu10mjAi+9u4VhB9aRTrgggpjygzY5 TDWoLvQYZPGsoPJAZE3EBGJWqHk6vfS4nSN6JX6M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 82ED13853836 for ; Mon, 24 May 2021 22:14:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 82ED13853836 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-iMEao65XNFeWVx5beKYWcg-1; Mon, 24 May 2021 18:14:10 -0400 X-MC-Unique: iMEao65XNFeWVx5beKYWcg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3168D803620 for ; Mon, 24 May 2021 22:14:10 +0000 (UTC) Received: from [10.3.114.34] (ovpn-114-34.phx2.redhat.com [10.3.114.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF7FD60C05 for ; Mon, 24 May 2021 22:14:09 +0000 (UTC) Subject: [PATCH 8/11] use xxx_no_warning APIs in Objective-C To: gcc-patches References: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Message-ID: <1e93eb13-f5f9-1029-4d91-d685cc05ce6a@redhat.com> Date: Mon, 24 May 2021 16:14:09 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The attached patch replaces the uses of TREE_NO_WARNING in the Objective-C front end. Add support for per-location warning groups. gcc/objc/ChangeLog: * objc-act.c (objc_maybe_build_modify_expr): Replace direct uses of TREE_NO_WARNING with get_no_warning, and set_no_warning. (objc_build_incr_expr_for_property_ref): Same. (objc_build_struct): Same. (synth_module_prologue): Same. * objc-gnu-runtime-abi-01.c (gnu_runtime_01_initialize): Same. * objc-next-runtime-abi-01.c (next_runtime_01_initialize): Same. * objc-next-runtime-abi-02.c (next_runtime_02_initialize): Same. diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 796256d437e..a4154709b00 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -2007,7 +2007,7 @@ objc_maybe_build_modify_expr (tree lhs, tree rhs) correct (maybe a more sophisticated implementation could avoid generating the compound expression if not needed), but we need to turn it off. */ - TREE_NO_WARNING (compound_expr) = 1; + set_no_warning (compound_expr, OPT_Wunused); return compound_expr; } else @@ -2129,7 +2129,7 @@ objc_build_incr_expr_for_property_ref (location_t location, /* Prevent C++ from warning with -Wall that "right operand of comma operator has no effect". */ - TREE_NO_WARNING (compound_expr) = 1; + set_no_warning (compound_expr, OPT_Wunused); return compound_expr; } @@ -2262,8 +2262,9 @@ objc_build_struct (tree klass, tree fields, tree super_name) DECL_FIELD_IS_BASE (base) = 1; if (fields) - TREE_NO_WARNING (fields) = 1; /* Suppress C++ ABI warnings -- we */ -#endif /* are following the ObjC ABI here. */ + /* Suppress C++ ABI warnings: we are following the ObjC ABI here. */ + set_no_warning (fields, OPT_Wabi); +#endif DECL_CHAIN (base) = fields; fields = base; } @@ -3112,19 +3113,19 @@ synth_module_prologue (void) TYPE_DECL, objc_object_name, objc_object_type)); - TREE_NO_WARNING (type) = 1; + set_no_warning (type); type = lang_hooks.decls.pushdecl (build_decl (input_location, TYPE_DECL, objc_instancetype_name, objc_instancetype_type)); - TREE_NO_WARNING (type) = 1; + set_no_warning (type); type = lang_hooks.decls.pushdecl (build_decl (input_location, TYPE_DECL, objc_class_name, objc_class_type)); - TREE_NO_WARNING (type) = 1; + set_no_warning (type); /* Forward-declare '@interface Protocol'. */ type = get_identifier (PROTOCOL_OBJECT_CLASS_NAME); diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c b/gcc/objc/objc-gnu-runtime-abi-01.c index 4add71edf41..9a63bbf45fd 100644 --- a/gcc/objc/objc-gnu-runtime-abi-01.c +++ b/gcc/objc/objc-gnu-runtime-abi-01.c @@ -213,7 +213,7 @@ static void gnu_runtime_01_initialize (void) TYPE_DECL, objc_selector_name, objc_selector_type)); - TREE_NO_WARNING (type) = 1; + set_no_warning (type); /* typedef id (*IMP)(id, SEL, ...); */ ftype = build_varargs_function_type_list (objc_object_type, diff --git a/gcc/objc/objc-next-runtime-abi-01.c b/gcc/objc/objc-next-runtime-abi-01.c index 3ec6e1703c1..b58e4829674 100644 --- a/gcc/objc/objc-next-runtime-abi-01.c +++ b/gcc/objc/objc-next-runtime-abi-01.c @@ -282,7 +282,7 @@ static void next_runtime_01_initialize (void) TYPE_DECL, objc_selector_name, objc_selector_type)); - TREE_NO_WARNING (type) = 1; + set_no_warning (type); build_v1_class_template (); build_super_template (); diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 3cfcd0b1a57..22266c6e612 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -379,7 +379,7 @@ static void next_runtime_02_initialize (void) TYPE_DECL, objc_selector_name, objc_selector_type)); - TREE_NO_WARNING (type) = 1; + set_no_warning (type); /* IMP : id (*) (id, _message_ref_t*, ...) SUPER_IMP : id (*) ( super_t*, _super_message_ref_t*, ...) From patchwork Mon May 24 22:15:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482989 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Mm9NcLhe; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fps350Fvlz9s24 for ; Tue, 25 May 2021 08:15:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7E067389364A; Mon, 24 May 2021 22:15:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E067389364A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621894510; bh=wro86vnpmbQBqWK86lKA1SlV3ojTfYtfaL3m8+mjlXA=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Mm9NcLhe2a+NQNWbgfbHJdbMeNyYEf9UPhZjVCj/mZIzKy5I+S5cr+EK5GvoRw1kK 9KJMRe5YL8KjFL36uxZ00USM6o4bA4iz0gKOtFh+Kq9vnrKDtGnbGTqKb/cTwR5o5e UZ23WXQduJ0aNkwymAvgY+3IBvxgX2NGodU4lcDk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 76B79383581E for ; Mon, 24 May 2021 22:15:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 76B79383581E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-XO6T2etSNH6Daq1cPvxAvQ-1; Mon, 24 May 2021 18:15:06 -0400 X-MC-Unique: XO6T2etSNH6Daq1cPvxAvQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B946C7400 for ; Mon, 24 May 2021 22:15:05 +0000 (UTC) Received: from [10.3.114.34] (ovpn-114-34.phx2.redhat.com [10.3.114.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0534B5D71D for ; Mon, 24 May 2021 22:15:04 +0000 (UTC) Subject: [PATCH 9/11] use xxx_no_warning APIs in rl78 back end To: gcc-patches References: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Message-ID: <49a6765f-5879-5fe2-2d8f-7ce52213a824@redhat.com> Date: Mon, 24 May 2021 16:15:04 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The attached patch replaces the uses of TREE_NO_WARNING in the rl78 back end. Add support for per-location warning groups. gcc/ChangeLog: * config/rl78/rl78.c (rl78_handle_naked_attribute): Replace a direct use of TREE_NO_WARNING with set_no_warning. diff --git a/gcc/config/rl78/rl78.c b/gcc/config/rl78/rl78.c index 4c34949a97f..1055d423c83 100644 --- a/gcc/config/rl78/rl78.c +++ b/gcc/config/rl78/rl78.c @@ -847,7 +847,7 @@ rl78_handle_naked_attribute (tree * node, /* Disable warnings about this function - eg reaching the end without seeing a return statement - because the programmer is doing things that gcc does not know about. */ - TREE_NO_WARNING (* node) = 1; + set_no_warning (* node); return NULL_TREE; } From patchwork Mon May 24 22:16:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482990 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=nFYzj2dT; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fps4F2SRbz9s24 for ; Tue, 25 May 2021 08:16:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 306D2388E810; Mon, 24 May 2021 22:16:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 306D2388E810 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621894571; bh=eE6vW2c81bJlfXVTiyJ6HYys3d946l7pCFB9UqJM5UY=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=nFYzj2dTgiSTOu9xKwLu2D6J5eeCf4uvmxuTn1abc2/+TPltbvILPTGPXpZ+d4CPq sY6uqKs5f4U+v0Z6OcqhUSo1H4OCUyaOWsww3/9bpRjymr3zwLcO3ng35Swz/+usoK cgLLQsdCJJvCX0Z5qy3BzRoiLSYhoUF+4MEwhO24= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 473A2383581E for ; Mon, 24 May 2021 22:16:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 473A2383581E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-524-p8ZBO3g3NVKfKDcHIFk4rQ-1; Mon, 24 May 2021 18:16:06 -0400 X-MC-Unique: p8ZBO3g3NVKfKDcHIFk4rQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 26DB3189C446 for ; Mon, 24 May 2021 22:16:06 +0000 (UTC) Received: from [10.3.114.34] (ovpn-114-34.phx2.redhat.com [10.3.114.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEE6719C79 for ; Mon, 24 May 2021 22:16:05 +0000 (UTC) Subject: [PATCH 10/11] use xxx_no_warning APIs in libcc1 To: gcc-patches References: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Message-ID: <6e17326a-3b70-ea6d-7524-adfeabe0772b@redhat.com> Date: Mon, 24 May 2021 16:16:05 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The attached patch replaces the uses of TREE_NO_WARNING in libc11. Add support for per-location warning groups. libcc1/ChangeLog: * libcp1plugin.cc (record_decl_address): Replace a direct use of TREE_NO_WARNING with set_no_warning. diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc index 79694b91964..469a75c7ff7 100644 --- a/libcc1/libcp1plugin.cc +++ b/libcc1/libcp1plugin.cc @@ -541,7 +541,7 @@ record_decl_address (plugin_context *ctx, decl_addr_value value) **slot = value; /* We don't want GCC to warn about e.g. static functions without a code definition. */ - TREE_NO_WARNING (value.decl) = 1; + set_no_warning (value.decl); return *slot; } From patchwork Mon May 24 22:16:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=kXEEEThx; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fps566p9Hz9s24 for ; Tue, 25 May 2021 08:16:58 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E433A383581E; Mon, 24 May 2021 22:16:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E433A383581E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621894617; bh=+3i8DD6ta7Qe+iOaus23TMm1jq81ZU82jkDf5KE962E=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=kXEEEThxekNLKhRs4km0BhEa/6fxKX3NRrlsxGBDPJ9DrWJZx+pFP3u0VhBcBjDt/ e7FDZjl1mVVN4vHEZetYYTFojcc+cKmNdxwcR5iMem7vFb5RCxBRTyfszkTDEPQllk mHAGhfKzWNE3m6gdNe7lZ9xDpAYU4N5bXkZM7WAo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 6EE98385481A for ; Mon, 24 May 2021 22:16:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6EE98385481A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-4Wiw8iYnNRSYhO8s_S3zkw-1; Mon, 24 May 2021 18:16:46 -0400 X-MC-Unique: 4Wiw8iYnNRSYhO8s_S3zkw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03768107ACC7 for ; Mon, 24 May 2021 22:16:46 +0000 (UTC) Received: from [10.3.114.34] (ovpn-114-34.phx2.redhat.com [10.3.114.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7843C60C05 for ; Mon, 24 May 2021 22:16:45 +0000 (UTC) Subject: [PATCH 11/11] use xxx_no_warning APIs in the middle end To: gcc-patches References: <92db3776-af59-fa20-483b-aa67b17d0751@gmail.com> <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> Message-ID: <9abe39b2-68cb-8381-68f8-c1a1ec73f108@redhat.com> Date: Mon, 24 May 2021 16:16:45 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <535d1b55-fc0a-63c3-08b5-48a017674d1e@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKTIP, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The attached patch replaces TREE_NO_WARNING, gimple_get_no_warning_p and gimple_set_no_warning with the new APIs, get_no_warning, set_no_warning, and copy_no_warning. Add support for per-location warning groups. gcc/ChangeLog: * builtins.c (warn_string_no_nul): Replace uses of TREE_NO_WARNING, gimple_no_warning_p and gimple_set_no_warning with get_no_warning, and set_no_warning. (c_strlen): Same. (maybe_warn_for_bound): Same. (warn_for_access): Same. (check_access): Same. (expand_builtin_strncmp): Same. (fold_builtin_varargs): Same. * calls.c (maybe_warn_nonstring_arg): Same. (maybe_warn_rdwr_sizes): Same. * cfgexpand.c (expand_call_stmt): Same. * cgraphunit.c (check_global_declaration): Same. * fold-const.c (fold_undefer_overflow_warnings): Same. (fold_truth_not_expr): Same. (fold_unary_loc): Same. (fold_checksum_tree): Same. * gengtype.c (open_base_files): Same. * gimple-array-bounds.cc (array_bounds_checker::check_array_ref): Same. (array_bounds_checker::check_mem_ref): Same. (array_bounds_checker::check_addr_expr): Same. (array_bounds_checker::check_array_bounds): Same. * gimple-expr.c (copy_var_decl): Same. * gimple-fold.c (gimple_fold_builtin_strcpy): Same. (gimple_fold_builtin_strncat): Same. (gimple_fold_builtin_stxcpy_chk): Same. (gimple_fold_builtin_stpcpy): Same. (gimple_fold_builtin_sprintf): Same. (fold_stmt_1): Same. * gimple-ssa-isolate-paths.c (diag_returned_locals): Same. * gimple-ssa-nonnull-compare.c (do_warn_nonnull_compare): Same. * gimple-ssa-sprintf.c (handle_printf_call): Same. * gimple-ssa-store-merging.c (imm_store_chain_info::output_merged_store): Same. * gimple-ssa-warn-restrict.c (maybe_diag_overlap): Same. (maybe_diag_access_bounds): Same. (check_call): Same. (check_bounds_or_overlap): Same. * gimple.c (gimple_build_call_from_tree): Same. * gimplify.c (gimplify_return_expr): Same. (gimplify_cond_expr): Same. (gimplify_modify_expr_complex_part): Same. (gimplify_modify_expr): Same. (gimple_push_cleanup): Same. (gimplify_expr): Same. * omp-expand.c (expand_omp_for_generic): Same. (expand_omp_taskloop_for_outer): Same. * omp-low.c (lower_rec_input_clauses): Same. (lower_lastprivate_clauses): Same. (lower_send_clauses): Same. (lower_omp_target): Same. * tree-cfg.c (pass_warn_function_return::execute): Same. * tree-complex.c (create_one_component_var): Same. * tree-inline.c (remap_gimple_op_r): Same. (copy_tree_body_r): Same. (declare_return_variable): Same. (expand_call_inline): Same. * tree-nested.c (lookup_field_for_decl): Same. * tree-sra.c (create_access_replacement): Same. (generate_subtree_copies): Same. * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Same. * tree-ssa-forwprop.c (combine_cond_expr_cond): Same. * tree-ssa-loop-ch.c (ch_base::copy_headers): Same. * tree-ssa-loop-im.c (execute_sm): Same. * tree-ssa-phiopt.c (cond_store_replacement): Same. * tree-ssa-strlen.c (maybe_warn_overflow): Same. (handle_builtin_strcpy): Same. (maybe_diag_stxncpy_trunc): Same. (handle_builtin_stxncpy_strncat): Same. (handle_builtin_strcat): Same. * tree-ssa-uninit.c (get_no_uninit_warning): Same. (set_no_uninit_warning): Same. (uninit_undefined_value_p): Same. (warn_uninit): Same. (maybe_warn_operand): Same. * tree-vrp.c (compare_values_warnv): Same. * vr-values.c (vr_values::extract_range_for_var_from_comparison_expr): Same. (test_for_singularity): Same. * gimple.h (get_no_warning): New. (set_no_warning): Same. (copy_no_warning): Same. (gimple_set_block): Call gimple_set_location. (gimple_set_location): Call copy_warning. (gimple_no_warning_p): Remove. (gimple_set_no_warning): Same. * tree.h (TREE_NO_WARNING): Remove. (get_no_warning): New. (set_no_warning): Same. (copy_no_warning): Same. diff --git a/gcc/builtins.c b/gcc/builtins.c index b0c880dc3b5..105deadd42b 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -1094,7 +1094,9 @@ warn_string_no_nul (location_t loc, tree expr, const char *fname, bool exact /* = false */, const wide_int bndrng[2] /* = NULL */) { - if ((expr && TREE_NO_WARNING (expr)) || TREE_NO_WARNING (arg)) + const int opt = OPT_Wstringop_overread; + if ((expr && get_no_warning (expr, opt)) + || get_no_warning (arg, opt)) return; loc = expansion_point_location_if_in_system_header (loc); @@ -1122,14 +1124,14 @@ warn_string_no_nul (location_t loc, tree expr, const char *fname, if (bndrng) { if (wi::ltu_p (maxsiz, bndrng[0])) - warned = warning_at (loc, OPT_Wstringop_overread, + warned = warning_at (loc, opt, "%K%qD specified bound %s exceeds " "maximum object size %E", expr, func, bndstr, maxobjsize); else { bool maybe = wi::to_wide (size) == bndrng[0]; - warned = warning_at (loc, OPT_Wstringop_overread, + warned = warning_at (loc, opt, exact ? G_("%K%qD specified bound %s exceeds " "the size %E of unterminated array") @@ -1144,7 +1146,7 @@ warn_string_no_nul (location_t loc, tree expr, const char *fname, } } else - warned = warning_at (loc, OPT_Wstringop_overread, + warned = warning_at (loc, opt, "%K%qD argument missing terminating nul", expr, func); } @@ -1153,14 +1155,14 @@ warn_string_no_nul (location_t loc, tree expr, const char *fname, if (bndrng) { if (wi::ltu_p (maxsiz, bndrng[0])) - warned = warning_at (loc, OPT_Wstringop_overread, + warned = warning_at (loc, opt, "%qs specified bound %s exceeds " "maximum object size %E", fname, bndstr, maxobjsize); else { bool maybe = wi::to_wide (size) == bndrng[0]; - warned = warning_at (loc, OPT_Wstringop_overread, + warned = warning_at (loc, opt, exact ? G_("%qs specified bound %s exceeds " "the size %E of unterminated array") @@ -1175,7 +1177,7 @@ warn_string_no_nul (location_t loc, tree expr, const char *fname, } } else - warned = warning_at (loc, OPT_Wstringop_overread, + warned = warning_at (loc, opt, "%qs argument missing terminating nul", fname); } @@ -1184,9 +1186,9 @@ warn_string_no_nul (location_t loc, tree expr, const char *fname, { inform (DECL_SOURCE_LOCATION (decl), "referenced argument declared here"); - TREE_NO_WARNING (arg) = 1; + set_no_warning (arg, opt); if (expr) - TREE_NO_WARNING (expr) = 1; + set_no_warning (expr, opt); } } @@ -1443,14 +1445,14 @@ c_strlen (tree arg, int only_value, c_strlen_data *data, unsigned eltsize) { /* Suppress multiple warnings for propagated constant strings. */ if (only_value != 2 - && !TREE_NO_WARNING (arg) + && !get_no_warning (arg/*, OPT_Warray_bounds*/) && warning_at (loc, OPT_Warray_bounds, "offset %qwi outside bounds of constant string", eltoff)) { if (decl) inform (DECL_SOURCE_LOCATION (decl), "%qE declared here", decl); - TREE_NO_WARNING (arg) = 1; + set_no_warning (arg, OPT_Warray_bounds); } return NULL_TREE; } @@ -3936,7 +3938,7 @@ static bool maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func, tree bndrng[2], tree size, const access_data *pad = NULL) { - if (!bndrng[0] || TREE_NO_WARNING (exp)) + if (!bndrng[0] || get_no_warning (exp, opt)) return false; tree maxobjsize = max_object_size (); @@ -4028,7 +4030,7 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func, inform (EXPR_LOCATION (pad->src.ref), "source object allocated here"); } - TREE_NO_WARNING (exp) = true; + set_no_warning (exp, opt); } return warned; @@ -4075,14 +4077,14 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func, return false; else if (tree_int_cst_equal (bndrng[0], bndrng[1])) warned = (func - ? warning_at (loc, OPT_Wstringop_overflow_, + ? warning_at (loc, opt, (maybe ? G_("%K%qD specified bound %E may exceed " "destination size %E") : G_("%K%qD specified bound %E exceeds " "destination size %E")), exp, func, bndrng[0], size) - : warning_at (loc, OPT_Wstringop_overflow_, + : warning_at (loc, opt, (maybe ? G_("%Kspecified bound %E may exceed " "destination size %E") @@ -4091,14 +4093,14 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func, exp, bndrng[0], size)); else warned = (func - ? warning_at (loc, OPT_Wstringop_overflow_, + ? warning_at (loc, opt, (maybe ? G_("%K%qD specified bound [%E, %E] may exceed " "destination size %E") : G_("%K%qD specified bound [%E, %E] exceeds " "destination size %E")), exp, func, bndrng[0], bndrng[1], size) - : warning_at (loc, OPT_Wstringop_overflow_, + : warning_at (loc, opt, (maybe ? G_("%Kspecified bound [%E, %E] exceeds " "destination size %E") @@ -4117,7 +4119,7 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func, inform (EXPR_LOCATION (pad->dst.ref), "destination object allocated here"); } - TREE_NO_WARNING (exp) = true; + set_no_warning (exp, opt); } return warned; @@ -4343,7 +4345,7 @@ warn_for_access (location_t loc, tree func, tree exp, int opt, tree range[2], exp, range[0], range[1], size)); if (warned) - TREE_NO_WARNING (exp) = true; + set_no_warning (exp, OPT_Wstringop_overread); return warned; } @@ -4386,7 +4388,7 @@ warn_for_access (location_t loc, tree func, tree exp, int opt, tree range[2], exp, range[0], range[1], size)); if (warned) - TREE_NO_WARNING (exp) = true; + set_no_warning (exp, OPT_Wstringop_overread); return warned; } @@ -4765,8 +4767,10 @@ check_access (tree exp, tree dstwrite, && tree_fits_uhwi_p (dstwrite) && tree_int_cst_lt (dstwrite, range[0])))) { - if (TREE_NO_WARNING (exp) - || (pad && pad->dst.ref && TREE_NO_WARNING (pad->dst.ref))) + const int opt = OPT_Wstringop_overflow_; + if (get_no_warning (exp, opt) + || (pad && pad->dst.ref + && get_no_warning (pad->dst.ref, opt))) return false; location_t loc = tree_inlined_location (exp); @@ -4777,12 +4781,12 @@ check_access (tree exp, tree dstwrite, and a source of unknown length. The call will write at least one byte past the end of the destination. */ warned = (func - ? warning_at (loc, OPT_Wstringop_overflow_, + ? warning_at (loc, opt, "%K%qD writing %E or more bytes into " "a region of size %E overflows " "the destination", exp, func, range[0], dstsize) - : warning_at (loc, OPT_Wstringop_overflow_, + : warning_at (loc, opt, "%Kwriting %E or more bytes into " "a region of size %E overflows " "the destination", @@ -4803,7 +4807,7 @@ check_access (tree exp, tree dstwrite, if (warned) { - TREE_NO_WARNING (exp) = true; + set_no_warning (exp, OPT_Wstringop_overflow_); if (pad) pad->dst.inform_access (pad->mode); } @@ -4876,19 +4880,21 @@ check_access (tree exp, tree dstwrite, if (overread) { - if (TREE_NO_WARNING (exp) - || (srcstr && TREE_NO_WARNING (srcstr)) - || (pad && pad->src.ref && TREE_NO_WARNING (pad->src.ref))) + const int opt = OPT_Wstringop_overread; + if (get_no_warning (exp, opt) + || (srcstr && get_no_warning (srcstr, opt)) + || (pad && pad->src.ref + && get_no_warning (pad->src.ref, opt))) return false; location_t loc = tree_inlined_location (exp); const bool read = mode == access_read_only || mode == access_read_write; const bool maybe = pad && pad->dst.parmarray; - if (warn_for_access (loc, func, exp, OPT_Wstringop_overread, range, - slen, false, read, maybe)) + if (warn_for_access (loc, func, exp, opt, range, slen, false, read, + maybe)) { - TREE_NO_WARNING (exp) = true; + set_no_warning (exp, opt); if (pad) pad->src.inform_access (access_read_only); } @@ -7413,8 +7419,7 @@ expand_builtin_strncmp (tree exp, ATTRIBUTE_UNUSED rtx target, /* Expand the library call ourselves using a stabilized argument list to avoid re-evaluating the function's arguments twice. */ tree call = build_call_nofold_loc (loc, fndecl, 3, arg1, arg2, len); - if (TREE_NO_WARNING (exp)) - TREE_NO_WARNING (call) = true; + copy_no_warning (call, exp); gcc_assert (TREE_CODE (call) == CALL_EXPR); CALL_EXPR_TAILCALL (call) = CALL_EXPR_TAILCALL (exp); return expand_call (call, target, target == const0_rtx); @@ -13953,7 +13958,7 @@ fold_builtin_varargs (location_t loc, tree fndecl, tree *args, int nargs) { ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret); SET_EXPR_LOCATION (ret, loc); - TREE_NO_WARNING (ret) = 1; + set_no_warning (ret); return ret; } return NULL_TREE; diff --git a/gcc/calls.c b/gcc/calls.c index f3da1839dc5..47e2a2b54de 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1622,7 +1622,7 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) if (!fndecl || !fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)) return false; - if (TREE_NO_WARNING (exp) || !warn_stringop_overread) + if (!warn_stringop_overread || get_no_warning (exp, OPT_Wstringop_overread)) return false; /* Avoid clearly invalid calls (more checking done below). */ @@ -1738,7 +1738,7 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) exp, fndecl, bndrng[0], bndrng[1], maxobjsize); if (warned) - TREE_NO_WARNING (exp) = true; + set_no_warning (exp, OPT_Wstringop_overread); return warned; } @@ -1915,7 +1915,7 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) } if (any_arg_warned) - TREE_NO_WARNING (exp) = true; + set_no_warning (exp, OPT_Wstringop_overread); return any_arg_warned; } @@ -1978,7 +1978,7 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) /* Set if a warning has been issued for any argument (used to decide whether to emit an informational note at the end). */ - bool any_warned = false; + int opt_warned = false; /* A string describing the attributes that the warnings issued by this function apply to. Used to print one informational note per function @@ -2053,7 +2053,7 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) *sizstr = '\0'; /* Set if a warning has been issued for the current argument. */ - bool arg_warned = false; + int arg_warned = 0; location_t loc = EXPR_LOCATION (exp); tree ptr = access.second.ptr; if (*sizstr @@ -2066,24 +2066,25 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) const std::string argtypestr = access.second.array_as_string (ptrtype); - arg_warned = warning_at (loc, OPT_Wstringop_overflow_, - "%Kbound argument %i value %s is " - "negative for a variable length array " - "argument %i of type %s", - exp, sizidx + 1, sizstr, - ptridx + 1, argtypestr.c_str ()); + if (warning_at (loc, OPT_Wstringop_overflow_, + "%Kbound argument %i value %s is " + "negative for a variable length array " + "argument %i of type %s", + exp, sizidx + 1, sizstr, + ptridx + 1, argtypestr.c_str ())) + arg_warned = OPT_Wstringop_overflow_; } - else - arg_warned = warning_at (loc, OPT_Wstringop_overflow_, - "%Kargument %i value %s is negative", - exp, sizidx + 1, sizstr); + else if (warning_at (loc, OPT_Wstringop_overflow_, + "%Kargument %i value %s is negative", + exp, sizidx + 1, sizstr)) + arg_warned = OPT_Wstringop_overflow_; if (arg_warned) { append_attrname (access, attrstr, sizeof attrstr); /* Remember a warning has been issued and avoid warning again below for the same attribute. */ - any_warned = true; + opt_warned = arg_warned; continue; } } @@ -2121,31 +2122,33 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) const std::string argtypestr = access.second.array_as_string (ptrtype); - arg_warned = warning_at (loc, OPT_Wnonnull, - "%Kargument %i of variable length " - "array %s is null but " - "the corresponding bound argument " - "%i value is %s", - exp, sizidx + 1, argtypestr.c_str (), - ptridx + 1, sizstr); + if (warning_at (loc, OPT_Wnonnull, + "%Kargument %i of variable length " + "array %s is null but " + "the corresponding bound argument " + "%i value is %s", + exp, sizidx + 1, argtypestr.c_str (), + ptridx + 1, sizstr)) + arg_warned = OPT_Wnonnull; } - else - arg_warned = warning_at (loc, OPT_Wnonnull, - "%Kargument %i is null but " - "the corresponding size argument " - "%i value is %s", - exp, ptridx + 1, sizidx + 1, - sizstr); + else if (warning_at (loc, OPT_Wnonnull, + "%Kargument %i is null but " + "the corresponding size argument " + "%i value is %s", + exp, ptridx + 1, sizidx + 1, + sizstr)) + arg_warned = OPT_Wnonnull; } else if (access_size && access.second.static_p) { /* Warn about null pointers for [static N] array arguments but do not warn for ordinary (i.e., nonstatic) arrays. */ - arg_warned = warning_at (loc, OPT_Wnonnull, - "%Kargument %i to %<%T[static %E]%> " - "is null where non-null expected", - exp, ptridx + 1, argtype, - access_size); + if (warning_at (loc, OPT_Wnonnull, + "%Kargument %i to %<%T[static %E]%> " + "is null where non-null expected", + exp, ptridx + 1, argtype, + access_size)) + arg_warned = OPT_Wnonnull; } if (arg_warned) @@ -2153,7 +2156,7 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) append_attrname (access, attrstr, sizeof attrstr); /* Remember a warning has been issued and avoid warning again below for the same attribute. */ - any_warned = true; + opt_warned = OPT_Wnonnull; continue; } } @@ -2189,17 +2192,17 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) /* Clear the no-warning bit in case it was set by check_access in a prior iteration so that accesses via different arguments are diagnosed. */ - TREE_NO_WARNING (exp) = false; + set_no_warning (exp, OPT_Wstringop_overflow_, false); access_mode mode = data.mode; if (mode == access_deferred) mode = TYPE_READONLY (argtype) ? access_read_only : access_read_write; check_access (exp, access_size, /*maxread=*/ NULL_TREE, srcsize, dstsize, mode, &data); - if (TREE_NO_WARNING (exp)) + if (get_no_warning (exp, OPT_Wstringop_overflow_)) + opt_warned = OPT_Wstringop_overflow_; + if (opt_warned) { - any_warned = true; - if (access.second.internal_p) inform (loc, "referencing argument %u of type %qT", ptridx + 1, ptrtype); @@ -2221,7 +2224,7 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) "in a call with type %qT and attribute %qs", fntype, attrstr); } - else if (any_warned) + else if (opt_warned) { if (fndecl) inform (DECL_SOURCE_LOCATION (fndecl), @@ -2232,7 +2235,7 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) } /* Set the bit in case if was cleared and not set above. */ - TREE_NO_WARNING (exp) = true; + set_no_warning (exp, opt_warned); } /* Fill in ARGS_SIZE and ARGS array based on the parameters found in diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 39e5b040427..fcc7cfd3b59 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -2807,9 +2807,6 @@ expand_call_stmt (gcall *stmt) if (gimple_call_nothrow_p (stmt)) TREE_NOTHROW (exp) = 1; - if (gimple_no_warning_p (stmt)) - TREE_NO_WARNING (exp) = 1; - CALL_EXPR_TAILCALL (exp) = gimple_call_tail_p (stmt); CALL_EXPR_MUST_TAIL_CALL (exp) = gimple_call_must_tail_p (stmt); CALL_EXPR_RETURN_SLOT_OPT (exp) = gimple_call_return_slot_opt_p (stmt); @@ -2823,6 +2820,9 @@ expand_call_stmt (gcall *stmt) CALL_EXPR_BY_DESCRIPTOR (exp) = gimple_call_by_descriptor_p (stmt); SET_EXPR_LOCATION (exp, gimple_location (stmt)); + /* Must come after copying location. */ + copy_no_warning (exp, stmt); + /* Ensure RTL is created for debug args. */ if (decl && DECL_HAS_DEBUG_ARGS_P (decl)) { diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 098eb99dc95..40489aab525 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1074,7 +1074,7 @@ check_global_declaration (symtab_node *snode) && ! DECL_ARTIFICIAL (decl) && ! TREE_PUBLIC (decl)) { - if (TREE_NO_WARNING (decl)) + if (get_no_warning (decl, OPT_Wunused)) ; else if (snode->referred_to_p (/*include_self=*/false)) pedwarn (input_location, 0, "%q+F used but never defined", decl); diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3be9c15e6b2..f3bc9ede30c 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -249,7 +249,7 @@ fold_undefer_overflow_warnings (bool issue, const gimple *stmt, int code) if (!issue || warnmsg == NULL) return; - if (gimple_no_warning_p (stmt)) + if (get_no_warning (stmt, OPT_Wstrict_overflow)) return; /* Use the smallest code level when deciding to issue the @@ -4249,8 +4249,7 @@ fold_truth_not_expr (location_t loc, tree arg) tree ret = build2_loc (loc, code, type, TREE_OPERAND (arg, 0), TREE_OPERAND (arg, 1)); - if (TREE_NO_WARNING (arg)) - TREE_NO_WARNING (ret) = 1; + copy_no_warning (ret, arg); return ret; } @@ -9341,7 +9340,7 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0) tem = fold_build1_loc (loc, code, type, TREE_OPERAND (op0, 1)); /* First do the assignment, then return converted constant. */ tem = build2_loc (loc, COMPOUND_EXPR, TREE_TYPE (tem), op0, tem); - TREE_NO_WARNING (tem) = 1; + set_no_warning (tem /* What warning? */); TREE_USED (tem) = 1; return tem; } @@ -13509,10 +13508,10 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, TYPE_CACHED_VALUES (tmp) = NULL; } } - else if (TREE_NO_WARNING (expr) && (DECL_P (expr) || EXPR_P (expr))) + else if (get_no_warning (expr) && (DECL_P (expr) || EXPR_P (expr))) { - /* Allow TREE_NO_WARNING to be set. Perhaps we shouldn't allow that - and change builtins.c etc. instead - see PR89543. */ + /* Allow the no-warning bit to be set. Perhaps we shouldn't allow + that and change builtins.c etc. instead - see PR89543. */ size_t sz = tree_size (expr); buf = XALLOCAVAR (union tree_node, sz); memcpy ((char *) buf, expr, sz); diff --git a/gcc/gengtype.c b/gcc/gengtype.c index b94e2f126ec..c1fa6d35c87 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -1727,7 +1727,7 @@ open_base_files (void) "target-globals.h", "ipa-ref.h", "cgraph.h", "symbol-summary.h", "ipa-prop.h", "ipa-fnsummary.h", "dwarf2out.h", "omp-general.h", "omp-offload.h", "ipa-modref-tree.h", "ipa-modref.h", "symtab-thunks.h", - "symtab-clones.h", + "symtab-clones.h", "diagnostic-spec.h", NULL }; const char *const *ifp; diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc index 199d9f5d216..41615002594 100644 --- a/gcc/gimple-array-bounds.cc +++ b/gcc/gimple-array-bounds.cc @@ -175,7 +175,7 @@ bool array_bounds_checker::check_array_ref (location_t location, tree ref, bool ignore_off_by_one) { - if (TREE_NO_WARNING (ref)) + if (get_no_warning (ref, OPT_Warray_bounds)) /* Return true to have the caller prevent warnings for enclosing refs. */ return true; @@ -346,7 +346,7 @@ array_bounds_checker::check_array_ref (location_t location, tree ref, /* Avoid more warnings when checking more significant subscripts of the same expression. */ ref = TREE_OPERAND (ref, 0); - TREE_NO_WARNING (ref) = 1; + set_no_warning (ref, OPT_Warray_bounds); if (decl) ref = decl; @@ -411,7 +411,7 @@ bool array_bounds_checker::check_mem_ref (location_t location, tree ref, bool ignore_off_by_one) { - if (TREE_NO_WARNING (ref)) + if (get_no_warning (ref, OPT_Warray_bounds)) return false; tree arg = TREE_OPERAND (ref, 0); @@ -770,7 +770,7 @@ array_bounds_checker::check_mem_ref (location_t location, tree ref, } } - TREE_NO_WARNING (ref) = 1; + set_no_warning (ref, OPT_Warray_bounds); return true; } @@ -787,7 +787,7 @@ array_bounds_checker::check_mem_ref (location_t location, tree ref, "intermediate array offset %wi is outside array bounds " "of %qT", tmpidx, reftype)) { - TREE_NO_WARNING (ref) = 1; + set_no_warning (ref, OPT_Warray_bounds); return true; } } @@ -818,7 +818,7 @@ array_bounds_checker::check_addr_expr (location_t location, tree t) warned = check_mem_ref (location, t, ignore_off_by_one); if (warned) - TREE_NO_WARNING (t) = true; + set_no_warning (t, OPT_Warray_bounds); t = TREE_OPERAND (t, 0); } @@ -826,7 +826,7 @@ array_bounds_checker::check_addr_expr (location_t location, tree t) if (TREE_CODE (t) != MEM_REF || TREE_CODE (TREE_OPERAND (t, 0)) != ADDR_EXPR - || TREE_NO_WARNING (t)) + || get_no_warning (t, OPT_Warray_bounds)) return; tree tem = TREE_OPERAND (TREE_OPERAND (t, 0), 0); @@ -886,7 +886,7 @@ array_bounds_checker::check_addr_expr (location_t location, tree t) if (DECL_P (t)) inform (DECL_SOURCE_LOCATION (t), "while referencing %qD", t); - TREE_NO_WARNING (t) = 1; + set_no_warning (t, OPT_Warray_bounds); } } @@ -980,9 +980,10 @@ array_bounds_checker::check_array_bounds (tree *tp, int *walk_subtree, See pr98266 and pr97595. */ *walk_subtree = false; - /* Propagate the no-warning bit to the outer expression. */ + /* Propagate the no-warning bit to the outer statement to avoid also + issuing -Wstringop-overflow/-overread for the out-of-bounds accesses. */ if (warned) - TREE_NO_WARNING (t) = true; + set_no_warning (wi->stmt, OPT_Warray_bounds); return NULL_TREE; } diff --git a/gcc/gimple-expr.c b/gcc/gimple-expr.c index b8c732b632a..80fba56ead4 100644 --- a/gcc/gimple-expr.c +++ b/gcc/gimple-expr.c @@ -377,7 +377,6 @@ copy_var_decl (tree var, tree name, tree type) DECL_ARTIFICIAL (copy) = DECL_ARTIFICIAL (var); DECL_IGNORED_P (copy) = DECL_IGNORED_P (var); DECL_CONTEXT (copy) = DECL_CONTEXT (var); - TREE_NO_WARNING (copy) = TREE_NO_WARNING (var); TREE_USED (copy) = 1; DECL_SEEN_IN_BIND_EXPR_P (copy) = 1; DECL_ATTRIBUTES (copy) = DECL_ATTRIBUTES (var); @@ -387,6 +386,7 @@ copy_var_decl (tree var, tree name, tree type) DECL_USER_ALIGN (copy) = 1; } + copy_no_warning (copy, var); return copy; } diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 68717cf1542..29dd361370a 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -2039,7 +2039,7 @@ gimple_fold_builtin_strcpy (gimple_stmt_iterator *gsi, not point to objects and so do not indicate an overlap; such calls could be the result of sanitization and jump threading). */ - if (!integer_zerop (dest) && !gimple_no_warning_p (stmt)) + if (!integer_zerop (dest) && !get_no_warning (stmt, OPT_Wrestrict)) { tree func = gimple_call_fndecl (stmt); @@ -2066,9 +2066,9 @@ gimple_fold_builtin_strcpy (gimple_stmt_iterator *gsi, if (nonstr) { /* Avoid folding calls with unterminated arrays. */ - if (!gimple_no_warning_p (stmt)) + if (!get_no_warning (stmt, OPT_Wstringop_overread)) warn_string_no_nul (loc, NULL_TREE, "strcpy", src, nonstr); - gimple_set_no_warning (stmt, true); + set_no_warning (stmt, OPT_Wstringop_overread); return false; } @@ -2476,7 +2476,7 @@ gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi) unsigned HOST_WIDE_INT dstsize; - bool nowarn = gimple_no_warning_p (stmt); + bool nowarn = get_no_warning (stmt, OPT_Wstringop_overflow_); if (!nowarn && compute_builtin_object_size (dst, 1, &dstsize)) { @@ -2499,7 +2499,7 @@ gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi) "destination size %wu"), stmt, fndecl, len, dstsize); if (nowarn) - gimple_set_no_warning (stmt, true); + set_no_warning (stmt, OPT_Wstringop_overflow_); } } @@ -2515,7 +2515,7 @@ gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi) if (warning_at (loc, OPT_Wstringop_overflow_, "%G%qD specified bound %E equals source length", stmt, fndecl, len)) - gimple_set_no_warning (stmt, true); + set_no_warning (stmt, OPT_Wstringop_overflow_); } tree fn = builtin_decl_implicit (BUILT_IN_STRCAT); @@ -3100,7 +3100,8 @@ gimple_fold_builtin_stxcpy_chk (gimple_stmt_iterator *gsi, not point to objects and so do not indicate an overlap; such calls could be the result of sanitization and jump threading). */ - if (!integer_zerop (dest) && !gimple_no_warning_p (stmt)) + if (!integer_zerop (dest) + && !get_no_warning (stmt, OPT_Wrestrict)) { tree func = gimple_call_fndecl (stmt); @@ -3283,10 +3284,10 @@ gimple_fold_builtin_stpcpy (gimple_stmt_iterator *gsi) if (data.decl) { /* Avoid folding calls with unterminated arrays. */ - if (!gimple_no_warning_p (stmt)) + if (!get_no_warning (stmt, OPT_Wstringop_overread)) warn_string_no_nul (loc, NULL_TREE, "stpcpy", src, data.decl, size, exact); - gimple_set_no_warning (stmt, true); + set_no_warning (stmt, OPT_Wstringop_overread); return false; } @@ -3550,8 +3551,7 @@ gimple_fold_builtin_sprintf (gimple_stmt_iterator *gsi) /* Propagate the NO_WARNING bit to avoid issuing the same warning more than once. */ - if (gimple_no_warning_p (stmt)) - gimple_set_no_warning (repl, true); + copy_no_warning (repl, stmt); gimple_seq_add_stmt_without_update (&stmts, repl); if (tree lhs = gimple_call_lhs (stmt)) @@ -3603,8 +3603,7 @@ gimple_fold_builtin_sprintf (gimple_stmt_iterator *gsi) /* Propagate the NO_WARNING bit to avoid issuing the same warning more than once. */ - if (gimple_no_warning_p (stmt)) - gimple_set_no_warning (repl, true); + copy_no_warning (repl, stmt); gimple_seq_add_stmt_without_update (&stmts, repl); if (tree lhs = gimple_call_lhs (stmt)) @@ -6062,7 +6061,7 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, bool inplace, tree (*valueize) (tree)) { bool changed = false; gimple *stmt = gsi_stmt (*gsi); - bool nowarning = gimple_no_warning_p (stmt); + bool nowarning = get_no_warning (stmt, OPT_Wstrict_overflow); unsigned i; fold_defer_overflow_warnings (); diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c index eb23cd41f4b..2dafe849ad3 100644 --- a/gcc/gimple-ssa-isolate-paths.c +++ b/gcc/gimple-ssa-isolate-paths.c @@ -400,6 +400,11 @@ diag_returned_locals (bool maybe, const locmap_t &locmap) gimple *stmt = (*it).first; const args_loc_t &argsloc = (*it).second; location_t stmtloc = gimple_location (stmt); + if (stmtloc == UNKNOWN_LOCATION) + /* When multiple return statements are merged into one it + may not have an associated location. Use the location + of the closing brace instead. */ + stmtloc = cfun->function_end_locus; auto_diagnostic_group d; unsigned nargs = argsloc.locvec.length (); diff --git a/gcc/gimple-ssa-nonnull-compare.c b/gcc/gimple-ssa-nonnull-compare.c index 9d7894633dc..517e791204f 100644 --- a/gcc/gimple-ssa-nonnull-compare.c +++ b/gcc/gimple-ssa-nonnull-compare.c @@ -97,7 +97,7 @@ do_warn_nonnull_compare (function *fun, tree arg) if (op && (POINTER_TYPE_P (TREE_TYPE (arg)) ? integer_zerop (op) : integer_minus_onep (op)) - && !gimple_no_warning_p (stmt)) + && !get_no_warning (stmt, OPT_Wnonnull_compare)) warning_at (loc, OPT_Wnonnull_compare, "% argument %qD compared to NULL", arg); } diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index fc744669e4b..ed69a73c183 100644 --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -4680,7 +4680,7 @@ handle_printf_call (gimple_stmt_iterator *gsi, pointer_query &ptr_qry) bool success = compute_format_length (info, &res, ptr_qry.rvals); if (res.warned) - gimple_set_no_warning (info.callstmt, true); + set_no_warning (info.callstmt, info.warnopt ()); /* When optimizing and the printf return value optimization is enabled, attempt to substitute the computed result for the return value of diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c index 123c92d9b44..51128f4482b 100644 --- a/gcc/gimple-ssa-store-merging.c +++ b/gcc/gimple-ssa-store-merging.c @@ -4348,10 +4348,12 @@ imm_store_chain_info::output_merged_store (merged_store_group *group) MR_DEPENDENCE_BASE (ops[j]) = base; } if (!integer_zerop (mask)) - /* The load might load some bits (that will be masked off - later on) uninitialized, avoid -W*uninitialized - warnings in that case. */ - TREE_NO_WARNING (ops[j]) = 1; + { + /* The load might load some bits (that will be masked + off later on) uninitialized, avoid -W*uninitialized + warnings in that case. */ + set_no_warning (ops[j], OPT_Wuninitialized); + } stmt = gimple_build_assign (make_ssa_name (dest_type), ops[j]); gimple_set_location (stmt, load_loc); @@ -4533,7 +4535,7 @@ imm_store_chain_info::output_merged_store (merged_store_group *group) provably uninitialized (no stores at all yet or previous store a CLOBBER) we'd optimize away the load and replace it e.g. with 0. */ - TREE_NO_WARNING (load_src) = 1; + set_no_warning (load_src, OPT_Wuninitialized); stmt = gimple_build_assign (tem, load_src); gimple_set_location (stmt, loc); gimple_set_vuse (stmt, new_vuse); diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c index ad37f20afaa..c4a773a45ff 100644 --- a/gcc/gimple-ssa-warn-restrict.c +++ b/gcc/gimple-ssa-warn-restrict.c @@ -1425,7 +1425,7 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs) if (!acs.overlap ()) return false; - if (gimple_no_warning_p (call)) + if (get_no_warning (call, OPT_Wrestrict)) return true; /* For convenience. */ @@ -1677,7 +1677,7 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs) validated. Return true if the offsets are not valid and a diagnostic has been issued, or would have been issued if DO_WARN had been true. */ -static bool +static int maybe_diag_access_bounds (gimple *call, tree func, int strict, const builtin_memref &ref, offset_int wroff, bool do_warn) @@ -1689,28 +1689,31 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, since the result is used to make codegen decisions. */ if (ref.sizrange[0] > maxobjsize) { + const int opt = OPT_Wstringop_overflow_; /* Return true without issuing a warning. */ if (!do_warn) - return true; + return opt; - if (ref.ref && TREE_NO_WARNING (ref.ref)) - return false; + if (ref.ref && get_no_warning (ref.ref, OPT_Wstringop_overflow_)) + return 0; + bool warned = false; if (warn_stringop_overflow) { if (ref.sizrange[0] == ref.sizrange[1]) - return warning_at (loc, OPT_Wstringop_overflow_, - "%G%qD specified bound %wu " - "exceeds maximum object size %wu", - call, func, ref.sizrange[0].to_uhwi (), - maxobjsize.to_uhwi ()); - - return warning_at (loc, OPT_Wstringop_overflow_, - "%G%qD specified bound between %wu and %wu " - "exceeds maximum object size %wu", - call, func, ref.sizrange[0].to_uhwi (), - ref.sizrange[1].to_uhwi (), - maxobjsize.to_uhwi ()); + warned = warning_at (loc, opt, + "%G%qD specified bound %wu " + "exceeds maximum object size %wu", + call, func, ref.sizrange[0].to_uhwi (), + maxobjsize.to_uhwi ()); + else + warned = warning_at (loc, opt, + "%G%qD specified bound between %wu and %wu " + "exceeds maximum object size %wu", + call, func, ref.sizrange[0].to_uhwi (), + ref.sizrange[1].to_uhwi (), + maxobjsize.to_uhwi ()); + return warned ? opt : 0; } } @@ -1732,8 +1735,8 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, if (!warn_array_bounds) return false; - if (TREE_NO_WARNING (ref.ptr) - || (ref.ref && TREE_NO_WARNING (ref.ref))) + if (get_no_warning (ref.ptr, OPT_Warray_bounds ) + || (ref.ref && get_no_warning (ref.ref, OPT_Warray_bounds))) return false; char rangestr[2][64]; @@ -1877,7 +1880,7 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, } } - return warned; + return warned ? OPT_Warray_bounds : 0; } /* Check a CALL statement for restrict-violations and issue warnings @@ -1888,7 +1891,7 @@ check_call (range_query *query, gimple *call) { /* Avoid checking the call if it has already been diagnosed for some reason. */ - if (gimple_no_warning_p (call)) + if (get_no_warning (call, OPT_Wrestrict)) return; tree func = gimple_call_fndecl (call); @@ -1974,11 +1977,12 @@ check_call (range_query *query, gimple *call) || (dstwr && !INTEGRAL_TYPE_P (TREE_TYPE (dstwr)))) return; - if (!check_bounds_or_overlap (query, call, dst, src, dstwr, NULL_TREE)) + int opt = check_bounds_or_overlap (query, call, dst, src, dstwr, NULL_TREE); + if (!opt) return; /* Avoid diagnosing the call again. */ - gimple_set_no_warning (call, true); + set_no_warning (call, OPT_Wrestrict); } } /* anonymous namespace */ @@ -2026,12 +2030,16 @@ check_bounds_or_overlap (range_query *query, /* Validate offsets to each reference before the access first to make sure they are within the bounds of the destination object if its size is known, or PTRDIFF_MAX otherwise. */ - if (maybe_diag_access_bounds (call, func, strict, dstref, wroff, do_warn) - || maybe_diag_access_bounds (call, func, strict, srcref, 0, do_warn)) + int opt + = maybe_diag_access_bounds (call, func, strict, dstref, wroff, do_warn); + if (!opt) + opt = maybe_diag_access_bounds (call, func, strict, srcref, 0, do_warn); + + if (opt) { if (do_warn) - gimple_set_no_warning (call, true); - return OPT_Warray_bounds; + set_no_warning (call, OPT_Wrestrict); + return opt; } if (!warn_restrict || bounds_only || !src) @@ -2058,12 +2066,12 @@ check_bounds_or_overlap (range_query *query, not point to objects and so do not indicate an overlap; such calls could be the result of sanitization and jump threading). */ - if (!integer_zerop (dst) && !gimple_no_warning_p (call)) + if (!integer_zerop (dst) && !get_no_warning (call, OPT_Wrestrict)) { warning_at (loc, OPT_Wrestrict, "%G%qD source argument is the same as destination", call, func); - gimple_set_no_warning (call, true); + set_no_warning (call, OPT_Wrestrict); return OPT_Wrestrict; } @@ -2073,7 +2081,7 @@ check_bounds_or_overlap (range_query *query, /* Return false when overlap has been detected. */ if (maybe_diag_overlap (loc, call, acs)) { - gimple_set_no_warning (call, true); + set_no_warning (call, OPT_Wrestrict); return OPT_Wrestrict; } diff --git a/gcc/gimple.c b/gcc/gimple.c index f1044e9c630..0ff1e9ab304 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -399,7 +399,7 @@ gimple_build_call_from_tree (tree t, tree fnptrtype) gimple_call_set_va_arg_pack (call, CALL_EXPR_VA_ARG_PACK (t)); gimple_call_set_nothrow (call, TREE_NOTHROW (t)); gimple_call_set_by_descriptor (call, CALL_EXPR_BY_DESCRIPTOR (t)); - gimple_set_no_warning (call, TREE_NO_WARNING (t)); + copy_no_warning (call, t); if (fnptrtype) { diff --git a/gcc/gimple.h b/gcc/gimple.h index 91b92b4a4d1..f95ce872cb5 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1634,6 +1634,21 @@ extern bool gimple_inexpensive_call_p (gcall *); extern bool stmt_can_terminate_bb_p (gimple *); extern location_t gimple_or_expr_nonartificial_location (gimple *, tree); +/* Return true if a warning is enabled for the statement. */ +extern bool get_no_warning (const gimple *, int = -1) + ATTRIBUTE_NONNULL (1); +/* Enable, or by default disable, a warning for the statement. */ +extern void set_no_warning (gimple *, int = -1, bool = true) + ATTRIBUTE_NONNULL (1); +/* Copy the warning disposition mapping from one statement to another. */ +extern void copy_no_warning (gimple *, const gimple *) + ATTRIBUTE_NONNULL (1) ATTRIBUTE_NONNULL (2); +/* Copy the warning disposition mapping from an expression to a statement. */ +extern void copy_no_warning (gimple *, const_tree) + ATTRIBUTE_NONNULL (1) ATTRIBUTE_NONNULL (2); +/* Copy the warning disposition mapping from a statement to an expression. */ +extern void copy_no_warning (tree, const gimple *) + ATTRIBUTE_NONNULL (1) ATTRIBUTE_NONNULL (2); /* Formal (expression) temporary table handling: multiple occurrences of the same scalar expression are evaluated into the same temporary. */ @@ -1854,16 +1869,17 @@ gimple_block (const gimple *g) return LOCATION_BLOCK (g->location); } +/* Forward declare. */ +static inline void gimple_set_location (gimple *, location_t); /* Set BLOCK to be the lexical scope block holding statement G. */ static inline void gimple_set_block (gimple *g, tree block) { - g->location = set_block (g->location, block); + gimple_set_location (g, set_block (g->location, block)); } - /* Return location information for statement G. */ static inline location_t @@ -1886,6 +1902,8 @@ gimple_location_safe (const gimple *g) static inline void gimple_set_location (gimple *g, location_t location) { + /* Copy the no-warning data to the statement location. */ + copy_no_warning (location, g->location); g->location = location; } @@ -1948,22 +1966,6 @@ gimple_seq_singleton_p (gimple_seq seq) && (gimple_seq_first (seq) == gimple_seq_last (seq))); } -/* Return true if no warnings should be emitted for statement STMT. */ - -static inline bool -gimple_no_warning_p (const gimple *stmt) -{ - return stmt->no_warning; -} - -/* Set the no_warning flag of STMT to NO_WARNING. */ - -static inline void -gimple_set_no_warning (gimple *stmt, bool no_warning) -{ - stmt->no_warning = (unsigned) no_warning; -} - /* Set the visited status on statement STMT to VISITED_P. Please note that this 'visited' property of the gimple statement is diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 719a4e16391..20445b89e27 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1596,7 +1596,7 @@ gimplify_return_expr (tree stmt, gimple_seq *pre_p) { maybe_add_early_return_predict_stmt (pre_p); greturn *ret = gimple_build_return (ret_expr); - gimple_set_no_warning (ret, TREE_NO_WARNING (stmt)); + copy_no_warning (ret, stmt); gimplify_seq_add_stmt (pre_p, ret); return GS_ALL_DONE; } @@ -1658,7 +1658,7 @@ gimplify_return_expr (tree stmt, gimple_seq *pre_p) we can wind up warning about an uninitialized value for this. Due to how this variable is constructed and initialized, this is never true. Give up and never warn. */ - TREE_NO_WARNING (result) = 1; + set_no_warning (result, OPT_Wuninitialized); gimplify_ctxp->return_temp = result; } @@ -1672,7 +1672,7 @@ gimplify_return_expr (tree stmt, gimple_seq *pre_p) maybe_add_early_return_predict_stmt (pre_p); ret = gimple_build_return (result); - gimple_set_no_warning (ret, TREE_NO_WARNING (stmt)); + copy_no_warning (ret, stmt); gimplify_seq_add_stmt (pre_p, ret); return GS_ALL_DONE; @@ -4244,7 +4244,8 @@ gimplify_cond_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback) &arm2); cond_stmt = gimple_build_cond (pred_code, arm1, arm2, label_true, label_false); - gimple_set_no_warning (cond_stmt, TREE_NO_WARNING (COND_EXPR_COND (expr))); + gimple_set_location (cond_stmt, EXPR_LOCATION (expr)); + copy_no_warning (cond_stmt, COND_EXPR_COND (expr)); gimplify_seq_add_stmt (&seq, cond_stmt); gimple_stmt_iterator gsi = gsi_last (seq); maybe_fold_stmt (&gsi); @@ -5694,7 +5695,7 @@ gimplify_modify_expr_complex_part (tree *expr_p, gimple_seq *pre_p, ocode = code == REALPART_EXPR ? IMAGPART_EXPR : REALPART_EXPR; other = build1 (ocode, TREE_TYPE (rhs), lhs); - TREE_NO_WARNING (other) = 1; + set_no_warning (other); other = get_formal_tmp_var (other, pre_p); realpart = code == REALPART_EXPR ? rhs : other; @@ -5979,7 +5980,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, assign = gimple_build_assign (*to_p, *from_p); gimple_set_location (assign, EXPR_LOCATION (*expr_p)); if (COMPARISON_CLASS_P (*from_p)) - gimple_set_no_warning (assign, TREE_NO_WARNING (*from_p)); + copy_no_warning (assign, *from_p); } if (gimplify_ctxp->into_ssa && is_gimple_reg (*to_p)) @@ -6738,7 +6739,7 @@ gimple_push_cleanup (tree var, tree cleanup, bool eh_only, gimple_seq *pre_p, /* Because of this manipulation, and the EH edges that jump threading cannot redirect, the temporary (VAR) will appear to be used uninitialized. Don't warn. */ - TREE_NO_WARNING (var) = 1; + set_no_warning (var, OPT_Wuninitialized); } } else @@ -14470,7 +14471,7 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, gimplify_and_add (EH_FILTER_FAILURE (*expr_p), &failure); ehf = gimple_build_eh_filter (EH_FILTER_TYPES (*expr_p), failure); - gimple_set_no_warning (ehf, TREE_NO_WARNING (*expr_p)); + copy_no_warning (ehf, *expr_p); gimplify_seq_add_stmt (pre_p, ehf); ret = GS_ALL_DONE; break; diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c index 0f843bad79a..dbccbfdeefa 100644 --- a/gcc/omp-expand.c +++ b/gcc/omp-expand.c @@ -3845,7 +3845,7 @@ expand_omp_for_generic (struct omp_region *region, for (i = first_zero_iter1; i < (fd->ordered ? fd->ordered : fd->collapse); i++) if (SSA_VAR_P (counts[i])) - TREE_NO_WARNING (counts[i]) = 1; + set_no_warning (counts[i], OPT_Wuninitialized); gsi_prev (&gsi); e = split_block (entry_bb, gsi_stmt (gsi)); entry_bb = e->dest; @@ -3862,7 +3862,7 @@ expand_omp_for_generic (struct omp_region *region, be executed in that case, so just avoid uninit warnings. */ for (i = first_zero_iter2; i < fd->ordered; i++) if (SSA_VAR_P (counts[i])) - TREE_NO_WARNING (counts[i]) = 1; + set_no_warning (counts[i], OPT_Wuninitialized); if (zero_iter1_bb) make_edge (zero_iter2_bb, entry_bb, EDGE_FALLTHRU); else @@ -7051,7 +7051,7 @@ expand_omp_taskloop_for_outer (struct omp_region *region, be executed in that case, so just avoid uninit warnings. */ for (i = first_zero_iter; i < fd->collapse; i++) if (SSA_VAR_P (counts[i])) - TREE_NO_WARNING (counts[i]) = 1; + set_no_warning (counts[i], OPT_Wuninitialized); gsi_prev (&gsi); edge e = split_block (entry_bb, gsi_stmt (gsi)); entry_bb = e->dest; diff --git a/gcc/omp-low.c b/gcc/omp-low.c index d1136d181b3..cb20fdf7609 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -5614,7 +5614,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, able to notice this and not store anything at all, but we're generating code too early. Suppress the warning. */ if (!by_ref) - TREE_NO_WARNING (var) = 1; + set_no_warning (var, OPT_Wuninitialized); break; case OMP_CLAUSE__CONDTEMP_: @@ -6575,7 +6575,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, uid = create_tmp_var (ptr_type_node, "simduid"); /* Don't want uninit warnings on simduid, it is always uninitialized, but we use it not for the value, but for the DECL_UID only. */ - TREE_NO_WARNING (uid) = 1; + set_no_warning (uid, OPT_Wuninitialized); c = build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE__SIMDUID_); OMP_CLAUSE__SIMDUID__DECL (c) = uid; OMP_CLAUSE_CHAIN (c) = gimple_omp_for_clauses (ctx->stmt); @@ -7003,7 +7003,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *body_p, if (predicate && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE || OMP_CLAUSE_LINEAR_NO_COPYIN (c))) - TREE_NO_WARNING (new_var) = 1; + set_no_warning (new_var, OPT_Wuninitialized); } if (!maybe_simt && simduid && DECL_HAS_VALUE_EXPR_P (new_var)) @@ -7834,7 +7834,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, gimple_seq *olist, if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c) && !by_ref && is_task_ctx (ctx)) - TREE_NO_WARNING (var) = 1; + set_no_warning (var); do_in = true; break; @@ -12388,7 +12388,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) { if (is_gimple_reg (var) && OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)) - TREE_NO_WARNING (var) = 1; + set_no_warning (var); var = build_fold_addr_expr (var); } else @@ -12412,7 +12412,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) we'll get a warning for the store to avar. Don't warn in that case, the mapping might be implicit. */ - TREE_NO_WARNING (var) = 1; + set_no_warning (var, OPT_Wuninitialized); gimplify_assign (avar, var, &ilist); } avar = build_fold_addr_expr (avar); @@ -12566,7 +12566,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) if (omp_is_reference (var)) t = build_simple_mem_ref (var); else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)) - TREE_NO_WARNING (var) = 1; + set_no_warning (var); if (TREE_CODE (type) != POINTER_TYPE) t = fold_convert (pointer_sized_int_node, t); t = fold_convert (TREE_TYPE (x), t); @@ -12579,7 +12579,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) tree avar = create_tmp_var (TREE_TYPE (var)); mark_addressable (avar); if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)) - TREE_NO_WARNING (var) = 1; + set_no_warning (var); gimplify_assign (avar, var, &ilist); avar = build_fold_addr_expr (avar); gimplify_assign (x, avar, &ilist); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 02256580c98..c85e9146508 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -9428,7 +9428,7 @@ pass_warn_function_return::execute (function *fun) /* If we see "return;" in some basic block, then we do reach the end without returning a value. */ else if (warn_return_type > 0 - && !TREE_NO_WARNING (fun->decl) + && !get_no_warning (fun->decl, OPT_Wreturn_type) && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (fun->decl)))) { FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (fun)->preds) @@ -9437,14 +9437,14 @@ pass_warn_function_return::execute (function *fun) greturn *return_stmt = dyn_cast (last); if (return_stmt && gimple_return_retval (return_stmt) == NULL - && !gimple_no_warning_p (last)) + && !get_no_warning (last, OPT_Wreturn_type)) { location = gimple_location (last); if (LOCATION_LOCUS (location) == UNKNOWN_LOCATION) location = fun->function_end_locus; if (warning_at (location, OPT_Wreturn_type, "control reaches end of non-void function")) - TREE_NO_WARNING (fun->decl) = 1; + set_no_warning (fun->decl, OPT_Wreturn_type); break; } } @@ -9452,7 +9452,7 @@ pass_warn_function_return::execute (function *fun) into __builtin_unreachable () call with BUILTINS_LOCATION. Recognize those too. */ basic_block bb; - if (!TREE_NO_WARNING (fun->decl)) + if (!get_no_warning (fun->decl, OPT_Wreturn_type)) FOR_EACH_BB_FN (bb, fun) if (EDGE_COUNT (bb->succs) == 0) { @@ -9476,7 +9476,7 @@ pass_warn_function_return::execute (function *fun) location = fun->function_end_locus; if (warning_at (location, OPT_Wreturn_type, "control reaches end of non-void function")) - TREE_NO_WARNING (fun->decl) = 1; + set_no_warning (fun->decl, OPT_Wreturn_type); break; } } diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index d7d991714de..c5d57346023 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -456,12 +456,12 @@ create_one_component_var (tree type, tree orig, const char *prefix, SET_DECL_DEBUG_EXPR (r, build1 (code, type, orig)); DECL_HAS_DEBUG_EXPR_P (r) = 1; DECL_IGNORED_P (r) = 0; - TREE_NO_WARNING (r) = TREE_NO_WARNING (orig); + copy_no_warning (r, orig); } else { DECL_IGNORED_P (r) = 1; - TREE_NO_WARNING (r) = 1; + set_no_warning (r); } return r; diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 8f945b88c12..2fea85c34bf 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1116,7 +1116,7 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data) *tp = fold_build2 (MEM_REF, type, ptr, TREE_OPERAND (*tp, 1)); TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old); TREE_SIDE_EFFECTS (*tp) = TREE_SIDE_EFFECTS (old); - TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old); + copy_no_warning (*tp, old); if (MR_DEPENDENCE_CLIQUE (old) != 0) { MR_DEPENDENCE_CLIQUE (*tp) @@ -1375,7 +1375,7 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) *tp = fold_build2 (MEM_REF, type, ptr, TREE_OPERAND (*tp, 1)); TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old); TREE_SIDE_EFFECTS (*tp) = TREE_SIDE_EFFECTS (old); - TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old); + copy_no_warning (*tp, old); if (MR_DEPENDENCE_CLIQUE (old) != 0) { MR_DEPENDENCE_CLIQUE (*tp) @@ -3753,7 +3753,7 @@ declare_return_variable (copy_body_data *id, tree return_slot, tree modify_dest, /* Do not have the rest of GCC warn about this variable as it should not be visible to the user. */ - TREE_NO_WARNING (var) = 1; + set_no_warning (var /* OPT_Wuninitialized? */); declare_inline_vars (id->block, var); @@ -5018,7 +5018,7 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id, initialized. We do not want to issue a warning about that uninitialized variable. */ if (DECL_P (modify_dest)) - TREE_NO_WARNING (modify_dest) = 1; + set_no_warning (modify_dest, OPT_Wuninitialized); if (gimple_call_return_slot_opt_p (call_stmt)) { diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index cea917a4d58..5d9e59134d2 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -411,8 +411,8 @@ lookup_field_for_decl (struct nesting_info *info, tree decl, DECL_USER_ALIGN (field) = DECL_USER_ALIGN (decl); DECL_IGNORED_P (field) = DECL_IGNORED_P (decl); DECL_NONADDRESSABLE_P (field) = !TREE_ADDRESSABLE (decl); - TREE_NO_WARNING (field) = TREE_NO_WARNING (decl); TREE_THIS_VOLATILE (field) = TREE_THIS_VOLATILE (decl); + copy_no_warning (field, decl); /* Declare the transformation and adjust the original DECL. For a variable or for a parameter when not optimizing, we make it point diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 8dfc923ed7e..2e3efc31666 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -2240,12 +2240,12 @@ create_access_replacement (struct access *access, tree reg_type = NULL_TREE) DECL_HAS_DEBUG_EXPR_P (repl) = 1; } if (access->grp_no_warning) - TREE_NO_WARNING (repl) = 1; + set_no_warning (repl /* Be more selective! */); else - TREE_NO_WARNING (repl) = TREE_NO_WARNING (access->base); + copy_no_warning (repl, access->base); } else - TREE_NO_WARNING (repl) = 1; + set_no_warning (repl /* Be more selective! */); if (dump_file) { @@ -3556,7 +3556,7 @@ generate_subtree_copies (struct access *access, tree agg, } else { - TREE_NO_WARNING (repl) = 1; + set_no_warning (repl /* Be more selective! */); if (access->grp_partial_lhs) repl = force_gimple_operand_gsi (gsi, repl, true, NULL_TREE, !insert_after, diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 3834212b867..f0303492f8e 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -3527,7 +3527,7 @@ pass_post_ipa_warn::execute (function *fun) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple *stmt = gsi_stmt (gsi); - if (!is_gimple_call (stmt) || gimple_no_warning_p (stmt)) + if (!is_gimple_call (stmt) || get_no_warning (stmt, OPT_Wnonnull)) continue; tree fntype = gimple_call_fntype (stmt); diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 0706fd862de..fa72ff007a2 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -403,7 +403,8 @@ combine_cond_expr_cond (gimple *stmt, enum tree_code code, tree type, return NULL_TREE; } - fold_undefer_overflow_warnings (!gimple_no_warning_p (stmt), stmt, 0); + bool nowarn = get_no_warning (stmt, OPT_Wstrict_overflow); + fold_undefer_overflow_warnings (!nowarn, stmt, 0); return t; } diff --git a/gcc/tree-ssa-loop-ch.c b/gcc/tree-ssa-loop-ch.c index 08caa83b4b4..9051820c8a7 100644 --- a/gcc/tree-ssa-loop-ch.c +++ b/gcc/tree-ssa-loop-ch.c @@ -458,7 +458,7 @@ ch_base::copy_headers (function *fun) && gimple_cond_code (stmt) != NE_EXPR && INTEGRAL_TYPE_P (TREE_TYPE (lhs)) && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (lhs))) - gimple_set_no_warning (stmt, true); + set_no_warning (stmt, OPT_Wstrict_overflow_); } else if (is_gimple_assign (stmt)) { @@ -469,7 +469,7 @@ ch_base::copy_headers (function *fun) && rhs_code != NE_EXPR && INTEGRAL_TYPE_P (TREE_TYPE (rhs1)) && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (rhs1))) - gimple_set_no_warning (stmt, true); + set_no_warning (stmt, OPT_Wstrict_overflow_); } } } diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index 8034cf68d27..64c63c6ee8b 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -2143,7 +2143,7 @@ execute_sm (class loop *loop, im_mem_ref *ref, /* If not emitting a load mark the uninitialized state on the loop entry as not to be warned for. */ tree uninit = create_tmp_reg (TREE_TYPE (aux->tmp_var)); - TREE_NO_WARNING (uninit) = 1; + set_no_warning (uninit, OPT_Wuninitialized); load = gimple_build_assign (aux->tmp_var, uninit); } lim_data = init_lim_data (load); diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 8e8a08bc679..58b764991ff 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -3014,9 +3014,12 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, new_stmt = gimple_build_assign (name, lhs); gimple_set_location (new_stmt, locus); lhs = unshare_expr (lhs); - /* Set TREE_NO_WARNING on the rhs of the load to avoid uninit - warnings. */ - TREE_NO_WARNING (gimple_assign_rhs1 (new_stmt)) = 1; + { + /* Set the no-warning bit on the rhs of the load to avoid uninit + warnings. */ + tree rhs1 = gimple_assign_rhs1 (new_stmt); + set_no_warning (rhs1, OPT_Wuninitialized); + } gsi_insert_on_edge (e1, new_stmt); /* 3) Create a PHI node at the join block, with one argument diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index c7b5e2c6e6b..88728a2c7f2 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -1918,7 +1918,7 @@ maybe_warn_overflow (gimple *stmt, tree len, pointer_query &ptr_qry, strinfo *si = NULL, bool plus_one = false, bool rawmem = false) { - if (!len || gimple_no_warning_p (stmt)) + if (!len || get_no_warning (stmt, OPT_Wstringop_overflow_)) return; /* The DECL of the function performing the write if it is done @@ -1937,7 +1937,7 @@ maybe_warn_overflow (gimple *stmt, tree len, pointer_query &ptr_qry, else return; - if (TREE_NO_WARNING (dest)) + if (get_no_warning (dest, OPT_Wstringop_overflow_)) return; const int ostype = rawmem ? 0 : 1; @@ -2081,7 +2081,7 @@ maybe_warn_overflow (gimple *stmt, tree len, pointer_query &ptr_qry, if (!warned) return; - gimple_set_no_warning (stmt, true); + set_no_warning (stmt, OPT_Wstringop_overflow_); aref.inform_access (access_write_only); } @@ -2605,15 +2605,15 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi, len = fold_build2_loc (loc, PLUS_EXPR, type, len, build_int_cst (type, 1)); /* Set the no-warning bit on the transformed statement? */ - bool set_no_warning = false; + int no_warning_opt = 0; - if (const strinfo *chksi = olddsi ? olddsi : dsi) - if (si - && check_bounds_or_overlap (stmt, chksi->ptr, si->ptr, NULL_TREE, len)) - { - gimple_set_no_warning (stmt, true); - set_no_warning = true; - } + if (const strinfo *chksi = si ? olddsi ? olddsi : dsi : NULL) + { + no_warning_opt = check_bounds_or_overlap (stmt, chksi->ptr, si->ptr, + NULL_TREE, len); + if (no_warning_opt) + set_no_warning (stmt, no_warning_opt); + } if (fn == NULL_TREE) return; @@ -2647,8 +2647,8 @@ handle_builtin_strcpy (enum built_in_function bcode, gimple_stmt_iterator *gsi, else if (dump_file && (dump_flags & TDF_DETAILS) != 0) fprintf (dump_file, "not possible.\n"); - if (set_no_warning) - gimple_set_no_warning (stmt, true); + if (no_warning_opt) + set_no_warning (stmt, no_warning_opt); } /* Check the size argument to the built-in forms of stpncpy and strncpy @@ -2776,7 +2776,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt, pointer_query *ptr_qry /* = NULL */) { gimple *stmt = gsi_stmt (gsi); - if (gimple_no_warning_p (stmt)) + if (get_no_warning (stmt, OPT_Wstringop_truncation)) return false; wide_int cntrange[2]; @@ -3135,9 +3135,9 @@ handle_builtin_stxncpy_strncat (bool append_p, gimple_stmt_iterator *gsi) else srclenp1 = NULL_TREE; - if (check_bounds_or_overlap (stmt, dst, src, dstlenp1, srclenp1)) + if (int opt = check_bounds_or_overlap (stmt, dst, src, dstlenp1, srclenp1)) { - gimple_set_no_warning (stmt, true); + set_no_warning (stmt, opt); return; } @@ -3148,7 +3148,7 @@ handle_builtin_stxncpy_strncat (bool append_p, gimple_stmt_iterator *gsi) if (!pss || pss->first <= 0) { if (maybe_diag_stxncpy_trunc (*gsi, src, len)) - gimple_set_no_warning (stmt, true); + set_no_warning (stmt, OPT_Wstringop_truncation); return; } @@ -3428,7 +3428,7 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi, } /* Set the no-warning bit on the transformed statement? */ - bool set_no_warning = false; + int no_warning_opt = 0; if (dsi == NULL || get_string_length (dsi) == NULL_TREE) { @@ -3445,12 +3445,10 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi, } tree sptr = si && si->ptr ? si->ptr : src; - - if (check_bounds_or_overlap (stmt, dst, sptr, NULL_TREE, slen)) - { - gimple_set_no_warning (stmt, true); - set_no_warning = true; - } + no_warning_opt = check_bounds_or_overlap (stmt, dst, sptr, NULL_TREE, + slen); + if (no_warning_opt) + set_no_warning (stmt, no_warning_opt); } /* strcat (p, q) can be transformed into @@ -3557,11 +3555,10 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi, tree dstsize = fold_build2 (PLUS_EXPR, type, dstlen, one); tree sptr = si && si->ptr ? si->ptr : src; - if (check_bounds_or_overlap (stmt, dst, sptr, dstsize, srcsize)) - { - gimple_set_no_warning (stmt, true); - set_no_warning = true; - } + no_warning_opt = check_bounds_or_overlap (stmt, dst, sptr, dstsize, + srcsize); + if (no_warning_opt) + set_no_warning (stmt, no_warning_opt); } tree len = NULL_TREE; @@ -3627,8 +3624,8 @@ handle_builtin_strcat (enum built_in_function bcode, gimple_stmt_iterator *gsi, else if (dump_file && (dump_flags & TDF_DETAILS) != 0) fprintf (dump_file, "not possible.\n"); - if (set_no_warning) - gimple_set_no_warning (stmt, true); + if (no_warning_opt) + set_no_warning (stmt, no_warning_opt); } /* Handle a call to an allocation function like alloca, malloc or calloc, diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index f55ce1939ac..e1d50ab92a7 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -86,17 +86,33 @@ has_undefined_value_p (tree t) && possibly_undefined_names->contains (t))); } -/* Like has_undefined_value_p, but don't return true if TREE_NO_WARNING - is set on SSA_NAME_VAR. */ +/* Return true if EXPR should suppress either uninitialized warning. */ + +static inline bool +get_no_uninit_warning (tree expr) +{ + return get_no_warning (expr, OPT_Wuninitialized); +} + +/* Suppress both uninitialized warnings for EXPR. */ + +static inline void +set_no_uninit_warning (tree expr) +{ + set_no_warning (expr, OPT_Wuninitialized); +} + +/* Like has_undefined_value_p, but don't return true if the no-warning + bit is set on SSA_NAME_VAR for either uninit warning. */ static inline bool uninit_undefined_value_p (tree t) { if (!has_undefined_value_p (t)) return false; - if (SSA_NAME_VAR (t) && TREE_NO_WARNING (SSA_NAME_VAR (t))) - return false; - return true; + if (!SSA_NAME_VAR (t)) + return true; + return !get_no_uninit_warning (SSA_NAME_VAR (t)); } /* Emit warnings for uninitialized variables. This is done in two passes. @@ -164,10 +180,10 @@ warn_uninit (enum opt_code wc, tree t, tree expr, tree var, /* TREE_NO_WARNING either means we already warned, or the front end wishes to suppress the warning. */ if ((context - && (gimple_no_warning_p (context) + && (get_no_warning (context, OPT_Wuninitialized) || (gimple_assign_single_p (context) - && TREE_NO_WARNING (gimple_assign_rhs1 (context))))) - || TREE_NO_WARNING (expr)) + && get_no_uninit_warning (gimple_assign_rhs1 (context))))) + || get_no_uninit_warning (expr)) return; if (context != NULL && gimple_has_location (context)) @@ -184,7 +200,7 @@ warn_uninit (enum opt_code wc, tree t, tree expr, tree var, auto_diagnostic_group d; if (warning_at (location, wc, gmsgid, expr)) { - TREE_NO_WARNING (expr) = 1; + set_no_warning (expr, wc); if (location == DECL_SOURCE_LOCATION (var)) return; @@ -259,7 +275,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs, use_operand_p luse_p; imm_use_iterator liter; - if (TREE_NO_WARNING (rhs)) + if (get_no_uninit_warning (rhs)) return NULL_TREE; /* Do not warn if the base was marked so or this is a @@ -267,7 +283,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs, tree base = ao_ref_base (&ref); if ((VAR_P (base) && DECL_HARD_REGISTER (base)) - || TREE_NO_WARNING (base)) + || get_no_uninit_warning (base)) return NULL_TREE; /* Do not warn if the access is fully outside of the variable. */ @@ -406,7 +422,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs, rhs = TREE_OPERAND (rhs, 0); /* Check again since RHS may have changed above. */ - if (TREE_NO_WARNING (rhs)) + if (get_no_uninit_warning (rhs)) return NULL_TREE; /* Avoid warning about empty types such as structs with no members. @@ -434,7 +450,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs, uses or accesses by functions as it may hide important locations. */ if (lhs) - TREE_NO_WARNING (rhs) = 1; + set_no_uninit_warning (rhs); warned = true; } } diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 12e6e6f3e22..d9aede22d6e 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -406,10 +406,10 @@ compare_values_warnv (tree val1, tree val2, bool *strict_overflow_p) return -2; if (strict_overflow_p != NULL - /* Symbolic range building sets TREE_NO_WARNING to declare + /* Symbolic range building sets the no-warning bit to declare that overflow doesn't happen. */ - && (!inv1 || !TREE_NO_WARNING (val1)) - && (!inv2 || !TREE_NO_WARNING (val2))) + && (!inv1 || !get_no_warning (val1, OPT_Woverflow)) + && (!inv2 || !get_no_warning (val2, OPT_Woverflow))) *strict_overflow_p = true; if (!inv1) @@ -432,10 +432,10 @@ compare_values_warnv (tree val1, tree val2, bool *strict_overflow_p) return -2; if (strict_overflow_p != NULL - /* Symbolic range building sets TREE_NO_WARNING to declare + /* Symbolic range building sets the no-warning bit to declare that overflow doesn't happen. */ - && (!sym1 || !TREE_NO_WARNING (val1)) - && (!sym2 || !TREE_NO_WARNING (val2))) + && (!sym1 || !get_no_warning (val1, OPT_Woverflow)) + && (!sym2 || !get_no_warning (val2, OPT_Woverflow))) *strict_overflow_p = true; const signop sgn = TYPE_SIGN (TREE_TYPE (val1)); diff --git a/gcc/tree.h b/gcc/tree.h index 64612cfa368..37593d0a3d8 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -699,13 +699,6 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, /* Determines whether an ENUMERAL_TYPE has defined the list of constants. */ #define ENUM_IS_OPAQUE(NODE) (ENUMERAL_TYPE_CHECK (NODE)->base.private_flag) -/* In an expr node (usually a conversion) this means the node was made - implicitly and should not lead to any sort of warning. In a decl node, - warnings concerning the decl should be suppressed. This is used at - least for used-before-set warnings, and it set after one warning is - emitted. */ -#define TREE_NO_WARNING(NODE) ((NODE)->base.nowarning_flag) - /* Nonzero if we should warn about the change in empty class parameter passing ABI in this TU. */ #define TRANSLATION_UNIT_WARN_EMPTY_P(NODE) \ @@ -6430,4 +6423,22 @@ public: operator location_t () const { return m_combined_loc; } }; +/* Return true if a warning is enabled for the decl/expression. */ +extern bool get_no_warning (const_tree, int = -1) ATTRIBUTE_NONNULL (1); +/* Enable, or by default disable, a warning for the expression. */ +extern void set_no_warning (tree, int = -1, bool = true) + ATTRIBUTE_NONNULL (1); +/* Copy the warning disposition mapping from one expression to another. */ +extern void copy_no_warning (tree, const_tree) + ATTRIBUTE_NONNULL (1) ATTRIBUTE_NONNULL (2); + +/* Return the disposition for a warning (or all warnings by default) + at a location. */ +extern bool get_no_warning (location_t, int = -1); +/* Set the disposition for a warning (or all warnings by default) + at a location to disabled by default. */ +extern bool set_no_warning (location_t, int = -1, bool = true); +/* Copy warning disposition from one location to another. */ +extern void copy_no_warning (location_t, location_t); + #endif /* GCC_TREE_H */ diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 02bc0db9088..67c0e35033a 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -697,7 +697,7 @@ vr_values::extract_range_for_var_from_comparison_expr (tree var, build_int_cst (TREE_TYPE (max), 1)); /* Signal to compare_values_warnv this expr doesn't overflow. */ if (EXPR_P (max)) - TREE_NO_WARNING (max) = 1; + set_no_warning (max, OPT_Woverflow); } vr_p->update (min, max); @@ -737,7 +737,7 @@ vr_values::extract_range_for_var_from_comparison_expr (tree var, build_int_cst (TREE_TYPE (min), 1)); /* Signal to compare_values_warnv this expr doesn't overflow. */ if (EXPR_P (min)) - TREE_NO_WARNING (min) = 1; + set_no_warning (min, OPT_Woverflow); } vr_p->update (min, max); @@ -3353,7 +3353,7 @@ test_for_singularity (enum tree_code cond_code, tree op0, max = fold_build2 (MINUS_EXPR, TREE_TYPE (op0), max, one); /* Signal to compare_values_warnv this expr doesn't overflow. */ if (EXPR_P (max)) - TREE_NO_WARNING (max) = 1; + set_no_warning (max, OPT_Woverflow); } } else if (cond_code == GE_EXPR || cond_code == GT_EXPR) @@ -3367,7 +3367,7 @@ test_for_singularity (enum tree_code cond_code, tree op0, min = fold_build2 (PLUS_EXPR, TREE_TYPE (op0), min, one); /* Signal to compare_values_warnv this expr doesn't overflow. */ if (EXPR_P (min)) - TREE_NO_WARNING (min) = 1; + set_no_warning (min, OPT_Woverflow); } }