public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-1142] Fix sanity checking of global_options.
Date: Tue,  1 Jun 2021 13:24:13 +0000 (GMT)	[thread overview]
Message-ID: <20210601132413.DD1093889805@sourceware.org> (raw)

https://gcc.gnu.org/g:b195d84561a5c31108c7bbbd7c5b63fe3cebe35f

commit r12-1142-gb195d84561a5c31108c7bbbd7c5b63fe3cebe35f
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Jun 1 10:41:04 2021 +0200

    Fix sanity checking of global_options.
    
    gcc/c-family/ChangeLog:
    
            PR other/100759
            * c-attribs.c (handle_optimize_attribute): Limit sanity check
            to a situation where we are not in processing of an optimize
            pragma.
            * c-pragma.c (handle_pragma_pop_options): Restore target
            options.

Diff:
---
 gcc/c-family/c-attribs.c | 6 +++++-
 gcc/c-family/c-pragma.c  | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 804374d5acc..156f7b3e8e1 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -5389,7 +5389,11 @@ handle_optimize_attribute (tree *node, tree name, tree args,
       /* If we previously had some optimization options, use them as the
 	 default.  */
       gcc_options *saved_global_options = NULL;
-      if (flag_checking)
+
+      /* When #pragma GCC optimize pragma is used, it modifies global_options
+	 without calling targetm.override_options_after_change.  That can leave
+	 target flags inconsistent for comparison.  */
+      if (flag_checking && optimization_current_node == optimization_default_node)
 	{
 	  saved_global_options = XNEW (gcc_options);
 	  *saved_global_options = global_options;
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index 7f658ea5646..f46b5b93c29 100644
--- a/gcc/c-family/c-pragma.c
+++ b/gcc/c-family/c-pragma.c
@@ -1088,6 +1088,8 @@ handle_pragma_pop_options (cpp_reader *ARG_UNUSED(dummy))
    * overwritten by invoke_set_current_function_hook.  */
   cl_optimization_restore (&global_options, &global_options_set,
 			   TREE_OPTIMIZATION (p->optimize_binary));
+  cl_target_option_restore (&global_options, &global_options_set,
+			    TREE_TARGET_OPTION (p->target_binary));
 
   if (p->optimize_binary != optimization_current_node)
     {


                 reply	other threads:[~2021-06-01 13:24 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=20210601132413.DD1093889805@sourceware.org \
    --to=marxin@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).