On Tue, 1 Dec 2015, Jan Hubicka wrote: > Hi, > this is third part which enables us to change -fstrict-aliasing using > optimize attribute. This ought to work safely now because inliner > propagate the flag.
Ok. Thanks, Richard. > Bootstrapped/regtested x86_64-linux. > > Honza > > * gcc.c-torture/execute/alias-1.c: New testcase. > * c-common.c: Do not silently ignore -fstrict-aliasing changes. > Index: testsuite/gcc.c-torture/execute/alias-1.c > =================================================================== > --- testsuite/gcc.c-torture/execute/alias-1.c (revision 0) > +++ testsuite/gcc.c-torture/execute/alias-1.c (revision 0) > @@ -0,0 +1,19 @@ > +int val; > + > +int *ptr = &val; > +float *ptr2 = &val; > + > +__attribute__((optimize ("-fno-strict-aliasing"))) > +typepun () > +{ > + *ptr2=0; > +} > + > +main() > +{ > + *ptr=1; > + typepun (); > + if (*ptr) > + __builtin_abort (); > +} > + > Index: c-family/c-common.c > =================================================================== > --- c-family/c-common.c (revision 231097) > +++ c-family/c-common.c (working copy) > @@ -9988,7 +9988,6 @@ parse_optimize_options (tree args, bool > bool ret = true; > unsigned opt_argc; > unsigned i; > - int saved_flag_strict_aliasing; > const char **opt_argv; > struct cl_decoded_option *decoded_options; > unsigned int decoded_options_count; > @@ -10081,8 +10080,6 @@ parse_optimize_options (tree args, bool > for (i = 1; i < opt_argc; i++) > opt_argv[i] = (*optimize_args)[i]; > > - saved_flag_strict_aliasing = flag_strict_aliasing; > - > /* Now parse the options. */ > decode_cmdline_options_to_array_default_mask (opt_argc, opt_argv, > &decoded_options, > @@ -10093,9 +10090,6 @@ parse_optimize_options (tree args, bool > > targetm.override_options_after_change(); > > - /* Don't allow changing -fstrict-aliasing. */ > - flag_strict_aliasing = saved_flag_strict_aliasing; > - > optimize_args->truncate (0); > return ret; > } > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)