re PR middle-end/79537 (ICE in gimplify_expr, at gimplify.c:12009)
authorMarek Polacek <polacek@redhat.com>
Mon, 20 Feb 2017 15:05:53 +0000 (15:05 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 20 Feb 2017 15:05:53 +0000 (15:05 +0000)
PR middle-end/79537
* gimplify.c (gimplify_expr): Handle unused *&&L;.

* gcc.dg/comp-goto-4.c: New.

From-SVN: r245604

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/comp-goto-4.c [new file with mode: 0644]

index a14d091a88dfd05cb0d257c4c90bd12ea6200e67..ab2e544d6d229bc9bbbc9c61129e7da7b62d3aec 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-20  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/79537
+       * gimplify.c (gimplify_expr): Handle unused *&&L;.
+
 2017-02-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/79568
index 1b9c8d23f1ac38fe8473e0e2240e1a342083ba08..820459c4dd76fb30c9563c780dd7d4961bad832f 100644 (file)
@@ -11976,8 +11976,11 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
   if (fallback == fb_none && *expr_p && !is_gimple_stmt (*expr_p))
     {
       /* We aren't looking for a value, and we don't have a valid
-        statement.  If it doesn't have side-effects, throw it away.  */
-      if (!TREE_SIDE_EFFECTS (*expr_p))
+        statement.  If it doesn't have side-effects, throw it away.
+        We can also get here with code such as "*&&L;", where L is
+        a LABEL_DECL that is marked as FORCED_LABEL.  */
+      if (TREE_CODE (*expr_p) == LABEL_DECL
+         || !TREE_SIDE_EFFECTS (*expr_p))
        *expr_p = NULL;
       else if (!TREE_THIS_VOLATILE (*expr_p))
        {
index c821a842c73c40edad82570de708a32925febdbb..bbe7ac9a4a487575f948970320667a5a55a8f78e 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-20  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/79537
+       * gcc.dg/comp-goto-4.c: New test.
+
 2017-02-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/79568
diff --git a/gcc/testsuite/gcc.dg/comp-goto-4.c b/gcc/testsuite/gcc.dg/comp-goto-4.c
new file mode 100644 (file)
index 0000000..51a6a86
--- /dev/null
@@ -0,0 +1,21 @@
+/* PR middle-end/79537 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+/* { dg-require-effective-target indirect_jumps } */
+/* { dg-require-effective-target label_values } */
+
+void
+f (void)
+{
+L:
+  *&&L;
+}
+
+void
+f2 (void)
+{
+   void *p;
+L:
+   p = &&L;
+   *p; /* { dg-warning "dereferencing 'void \\*' pointer" } */
+}