re PR sanitizer/80067 (ICE in fold_comparison with -fsanitize=undefined)
authorMarek Polacek <polacek@redhat.com>
Tue, 28 Mar 2017 08:13:04 +0000 (08:13 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 28 Mar 2017 08:13:04 +0000 (08:13 +0000)
PR sanitizer/80067
* fold-const.c (fold_comparison): Use protected_set_expr_location
instead of SET_EXPR_LOCATION.

* c-c++-common/ubsan/shift-10.c: New test.

From-SVN: r246521

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/ubsan/shift-10.c [new file with mode: 0644]

index 062afce6669085479c3c8315219aa80a14e0732e..691785926be6ddb2a6d14536dd3a33ad2fc87b89 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-28  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/80067
+       * fold-const.c (fold_comparison): Use protected_set_expr_location
+       instead of SET_EXPR_LOCATION.
+
 2017-03-28  Markus Trippelsdorf  <markus@trippelsdorf.de>
 
        * tree.c (add_expr): Avoid name lookup warning.
index 1a9a264fc260c9ddf5fa0a8d3b246939566ecb38..6db16b514f1f32efd2e0a9beb2bb402c6137a398 100644 (file)
@@ -8704,7 +8704,7 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
              if (save_p)
                {
                  tem = save_expr (build2 (code, type, cval1, cval2));
-                 SET_EXPR_LOCATION (tem, loc);
+                 protected_set_expr_location (tem, loc);
                  return tem;
                }
              return fold_build2_loc (loc, code, type, cval1, cval2);
index 086be297bd3d978ed05783310051be64d32708f0..93c9f9efed492afcd1abcab80d93a4224157bb44 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-28  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/80067
+       * c-c++-common/ubsan/shift-10.c: New test.
+
 2017-03-27  Jeff Law  <law@redhat.com>
 
        PR tree-optimization/80216
diff --git a/gcc/testsuite/c-c++-common/ubsan/shift-10.c b/gcc/testsuite/c-c++-common/ubsan/shift-10.c
new file mode 100644 (file)
index 0000000..9202fcc
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR sanitizer/80067 */
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=shift" } */
+
+extern signed char a;
+void
+foo ()
+{
+  0 << ((647 > a) - 1);
+}