public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Sebor <msebor@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-2178] Move warning suppression to the ultimate callee.
Date: Thu,  8 Jul 2021 22:40:57 +0000 (GMT)	[thread overview]
Message-ID: <20210708224057.DDB9E393A02A@sourceware.org> (raw)

https://gcc.gnu.org/g:79d3378c7d73814442eb468c562ab8aa572f9c43

commit r12-2178-g79d3378c7d73814442eb468c562ab8aa572f9c43
Author: Martin Sebor <msebor@redhat.com>
Date:   Thu Jul 8 16:36:15 2021 -0600

    Move warning suppression to the ultimate callee.
    
    Resolves:
    PR bootstrap/101372 - -Warray-bounds in gcc/cp/module.cc causing bootstrap failure
    
    gcc/cp/ChangeLog:
    
            PR bootstrap/101372
            * module.cc (identifier): Suppress warning.
            (module_state::read_macro_maps): Remove warning suppression.
            (module_state::install_macros): Ditto.

Diff:
---
 gcc/cp/module.cc | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 8a890c167cf..ccbde292c22 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -274,7 +274,14 @@ static inline cpp_hashnode *cpp_node (tree id)
 
 static inline tree identifier (const cpp_hashnode *node)
 {
+  /* HT_NODE() expands to node->ident that HT_IDENT_TO_GCC_IDENT()
+     then subtracts a nonzero constant, deriving a pointer to
+     a different member than ident.  That's strictly undefined
+     and detected by -Warray-bounds.  Suppress it.  See PR 101372.  */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
   return HT_IDENT_TO_GCC_IDENT (HT_NODE (const_cast<cpp_hashnode *> (node)));
+#pragma GCC diagnostic pop
 }
 
 /* Id for dumping module information.  */
@@ -16301,18 +16308,11 @@ module_state::read_macro_maps ()
 	}
       if (count)
 	sec.set_overrun ();
-
-      /* FIXME: Re-enable or fix after root causing.  */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Warray-bounds"
-
       dump (dumper::LOCATION)
 	&& dump ("Macro:%u %I %u/%u*2 locations [%u,%u)",
 		 ix, identifier (node), runs, n_tokens,
 		 MAP_START_LOCATION (macro),
 		 MAP_START_LOCATION (macro) + n_tokens);
-
-#pragma GCC diagnostic pop
     }
   location_t lwm = sec.u ();
   macro_locs.first = lwm - slurp->loc_deltas.second;
@@ -16918,10 +16918,6 @@ module_state::install_macros ()
       macro_import::slot &slot = imp.append (mod, flags);
       slot.offset = sec.u ();
 
-      /* FIXME: Re-enable or fix after root causing.  */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Warray-bounds"
-
       dump (dumper::MACRO)
 	&& dump ("Read %s macro %s%s%s %I at %u",
 		 imp.length () > 1 ? "add" : "new",
@@ -16942,8 +16938,6 @@ module_state::install_macros ()
 	    exp.def = cur;
 	    dump (dumper::MACRO)
 	      && dump ("Saving current #define %I", identifier (node));
-
-#pragma GCC diagnostic pop
 	  }
     }


                 reply	other threads:[~2021-07-08 22:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210708224057.DDB9E393A02A@sourceware.org \
    --to=msebor@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).