alias-1.c: New testcase.
authorJan Hubicka <hubicka@ucw.cz>
Tue, 1 Dec 2015 19:14:44 +0000 (20:14 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 1 Dec 2015 19:14:44 +0000 (19:14 +0000)
* gcc.c-torture/execute/alias-1.c: New testcase.
* c-common.c: Do not silently ignore -fstrict-aliasing changes.

From-SVN: r231125

gcc/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/alias-1.c [new file with mode: 0644]

index d5aa3d6e3c80b6facd5ccaabf5e9f8563060f611..f90b4cdfb8aba4d397ef598aa46d13ddab99227a 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-01  Jan Hubicka  <hubicka@ucw.cz>
+
+       * c-common.c (parse_optimize_options): Do not silently ignore
+       -fstrict-aliasing changes.
+
 2015-12-01  Jan Hubicka  <hubicka@ucw.cz>
 
        * lto-streamer-out.c (hash_tree): Do not stream TYPE_ALIAS_SET.
index 369574f44de697220bb91cf0d4a0a82431a117fd..7a9e3b98b68cc6c7e60cab2ce8dfbb5454c0151c 100644 (file)
@@ -9988,7 +9988,6 @@ parse_optimize_options (tree args, bool attr_p)
   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 attr_p)
   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 attr_p)
 
   targetm.override_options_after_change();
 
-  /* Don't allow changing -fstrict-aliasing.  */
-  flag_strict_aliasing = saved_flag_strict_aliasing;
-
   optimize_args->truncate (0);
   return ret;
 }
index ef5a175b43c6330f968349c7f1d76f025a45c486..7fd8b5540173dbe93f93e50ac6babef12adfa42f 100644 (file)
@@ -1,3 +1,7 @@
+2015-12-01  Jan Hubicka  <hubicka@ucw.cz>
+
+       * gcc.c-torture/execute/alias-1.c: New testcase.
+
 2015-12-01  Marek Polacek  <polacek@redhat.com>
 
        PR tree-optimization/64769
diff --git a/gcc/testsuite/gcc.c-torture/execute/alias-1.c b/gcc/testsuite/gcc.c-torture/execute/alias-1.c
new file mode 100644 (file)
index 0000000..666e96f
--- /dev/null
@@ -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 ();
+}
+