aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2019-12-10 19:41:08 +0100
committerMartin Liska <mliska@suse.cz>2020-06-10 10:04:14 +0200
commitdc6d15eaa23cbae1468a6ef92371b1c856c14819 (patch)
tree954a57a5125fe9d401fbc977c6897a783e8cc47f /gcc/c-family
parent771e60dd073b4dc0663fa9282b854dafdd92242d (diff)
downloadgcc-dc6d15eaa23cbae1468a6ef92371b1c856c14819.zip
gcc-dc6d15eaa23cbae1468a6ef92371b1c856c14819.tar.gz
gcc-dc6d15eaa23cbae1468a6ef92371b1c856c14819.tar.bz2
Add gcc_assert that &global_options are not dirty modified.
gcc/ChangeLog: 2020-03-20 Martin Liska <mliska@suse.cz> PR tree-optimization/92860 * optc-save-gen.awk: Generate new function cl_optimization_compare. * opth-gen.awk: Generate declaration of the function. gcc/c-family/ChangeLog: 2020-03-20 Martin Liska <mliska@suse.cz> PR tree-optimization/92860 * c-attribs.c (handle_optimize_attribute): Save global options and compare it after parsing of function attribute. * c-pragma.c (opt_stack::saved_global_options): New field. (handle_pragma_push_options): Save global_options. (handle_pragma_pop_options): Compare them after pop.
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-attribs.c12
-rw-r--r--gcc/c-family/c-pragma.c11
2 files changed, 23 insertions, 0 deletions
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 193c4cd..3721483 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -4452,6 +4452,13 @@ 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)
+ {
+ saved_global_options = XNEW (gcc_options);
+ *saved_global_options = global_options;
+ }
+
if (old_opts)
cl_optimization_restore (&global_options,
TREE_OPTIMIZATION (old_opts));
@@ -4463,6 +4470,11 @@ handle_optimize_attribute (tree *node, tree name, tree args,
/* Restore current options. */
cl_optimization_restore (&global_options, &cur_opts);
+ if (saved_global_options != NULL)
+ {
+ cl_optimization_compare (saved_global_options, &global_options);
+ free (saved_global_options);
+ }
}
return NULL_TREE;
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index 7c35741..e3169e6 100644
--- a/gcc/c-family/c-pragma.c
+++ b/gcc/c-family/c-pragma.c
@@ -1003,6 +1003,7 @@ struct GTY(()) opt_stack {
tree target_strings;
tree optimize_binary;
tree optimize_strings;
+ gcc_options * GTY ((skip)) saved_global_options;
};
static GTY(()) struct opt_stack * options_stack;
@@ -1028,6 +1029,11 @@ handle_pragma_push_options (cpp_reader *ARG_UNUSED(dummy))
options_stack = p;
/* Save optimization and target flags in binary format. */
+ if (flag_checking)
+ {
+ p->saved_global_options = XNEW (gcc_options);
+ *p->saved_global_options = global_options;
+ }
p->optimize_binary = build_optimization_node (&global_options);
p->target_binary = build_target_option_node (&global_options);
@@ -1079,6 +1085,11 @@ handle_pragma_pop_options (cpp_reader *ARG_UNUSED(dummy))
p->optimize_binary);
optimization_current_node = p->optimize_binary;
}
+ if (flag_checking)
+ {
+ cl_optimization_compare (p->saved_global_options, &global_options);
+ free (p->saved_global_options);
+ }
current_target_pragma = p->target_strings;
current_optimize_pragma = p->optimize_strings;