From: Richard Biener Date: Tue, 7 Jun 2016 12:41:46 +0000 (+0000) Subject: re PR c++/61564 (#pragma GCC optimize ("-fno-lto") causes the compiler to crash) X-Git-Tag: upstream/12.2.0~46576 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bfd67b47314d862a8de101a96b39c6efe543f92e;p=platform%2Fupstream%2Fgcc.git re PR c++/61564 (#pragma GCC optimize ("-fno-lto") causes the compiler to crash) 2016-06-07 Richard Biener PR c/61564 * c-common.c (parse_optimize_options): Only apply CL_OPTIMIZATION options and warn about others. * common.opt (ffast-math): Make Optimization. * gcc.dg/Wpragmas-1.c: New testcase. * gcc.dg/Wattributes-4.c: Likewise. * gcc.dg/ipa/pr70646.c: Drop optimize pragma in favor of dg-option entry. From-SVN: r237174 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4b278b1..64ec93f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-06-07 Richard Biener + + PR c/61564 + * common.opt (ffast-math): Make Optimization. + 2016-06-07 Simon Dardis Prachi Godbole diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7c589ac..6d8307d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2016-06-07 Richard Biener + + PR c/61564 + * c-common.c (parse_optimize_options): Only apply CL_OPTIMIZATION + options and warn about others. + 2016-06-01 Eduard Sanou * c-common.c (get_source_date_epoch): Rename to diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 93ca274..2e29dfc 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -9580,6 +9580,29 @@ parse_optimize_options (tree args, bool attr_p) decode_cmdline_options_to_array_default_mask (opt_argc, opt_argv, &decoded_options, &decoded_options_count); + /* Drop non-Optimization options. */ + unsigned j = 1; + for (i = 1; i < decoded_options_count; ++i) + { + if (! (cl_options[decoded_options[i].opt_index].flags & CL_OPTIMIZATION)) + { + ret = false; + if (attr_p) + warning (OPT_Wattributes, + "bad option %s to optimize attribute", + decoded_options[i].orig_option_with_args_text); + else + warning (OPT_Wpragmas, + "bad option %s to pragma attribute", + decoded_options[i].orig_option_with_args_text); + continue; + } + if (i != j) + decoded_options[j] = decoded_options[i]; + j++; + } + decoded_options_count = j; + /* And apply them. */ decode_options (&global_options, &global_options_set, decoded_options, decoded_options_count, input_location, global_dc); diff --git a/gcc/common.opt b/gcc/common.opt index 632dd31..f0d7196 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1287,7 +1287,7 @@ EnumValue Enum(excess_precision) String(standard) Value(EXCESS_PRECISION_STANDARD) ffast-math -Common +Common Optimization ffat-lto-objects Common Var(flag_fat_lto_objects) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 14bcd13..33540ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2016-06-07 Richard Biener + + PR c/61564 + * gcc.dg/Wpragmas-1.c: New testcase. + * gcc.dg/Wattributes-4.c: Likewise. + * gcc.dg/ipa/pr70646.c: Drop optimize pragma in favor of dg-option + entry. + 2016-06-07 Christophe Lyon * gcc.target/aarch64/advsimd-intrinsics/p64_p128.c: Remove diff --git a/gcc/testsuite/gcc.dg/Wattributes-4.c b/gcc/testsuite/gcc.dg/Wattributes-4.c new file mode 100644 index 0000000..abda5a3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wattributes-4.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ + +int __attribute__((optimize("no-lto"))) main(void){return 0;} /* { dg-warning "bad option" } */ diff --git a/gcc/testsuite/gcc.dg/Wpragmas-1.c b/gcc/testsuite/gcc.dg/Wpragmas-1.c new file mode 100644 index 0000000..139519e --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wpragmas-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +#pragma GCC push_options +#pragma GCC optimize ("-fno-lto") /* { dg-warning "bad option" } */ +int main(void){return 0;} +#pragma GCC pop_options + +/* ??? The FEs still apply the pragma string as optimize attribute to + all functions thus the diagnostic will be repeated for each function + affected. */ +/* { dg-message "bad option" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.dg/ipa/pr70646.c b/gcc/testsuite/gcc.dg/ipa/pr70646.c index f85816e..ba6f781 100644 --- a/gcc/testsuite/gcc.dg/ipa/pr70646.c +++ b/gcc/testsuite/gcc.dg/ipa/pr70646.c @@ -1,7 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O2" } */ - -#pragma GCC optimize("no-unit-at-a-time") +/* { dg-options "-O2 -fno-unit-at-a-time" } */ typedef unsigned char u8; typedef unsigned long long u64;