]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/6196 (ICE in copy_to_mode_reg, at explow.c:711)
authorMark Mitchell <mark@codesourcery.com>
Fri, 29 Aug 2003 23:11:14 +0000 (23:11 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 29 Aug 2003 23:11:14 +0000 (23:11 +0000)
PR c++/6196
* pt.c (tsubst_copy_and_build): Correct handling of
address-of-label extension.
* semantics.c (finish_goto_stmt): The address of a label must go
through the lvalue-to-rvalue conversion.

PR c++/6196
* g++.dg/ext/label1.C: New test.
* g++.dg/ext/label2.C: Likewise.

From-SVN: r70932

gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/label1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/label2.C [new file with mode: 0644]

index 45bec17520c3b901cf2865ee1d33b36ce10b16ab..ff3518e069a3118945d858f2f84dd3de1c84f1af 100644 (file)
@@ -7972,6 +7972,8 @@ tsubst_copy_and_build (tree t,
       else
        op1 = tsubst_non_call_postfix_expression (op1, args, complain, 
                                                  in_decl);
+      if (TREE_CODE (op1) == LABEL_DECL)
+       return finish_label_address_expr (DECL_NAME (op1));
       return build_x_unary_op (ADDR_EXPR, op1);
 
     case PLUS_EXPR:
index ee80beefad6a9189a00f0ca6c68c51349d8ccf03..c38bdd3681a0677d1d8834e5b6c1d2dbd265146c 100644 (file)
@@ -378,13 +378,17 @@ finish_goto_stmt (tree destination)
      mark the used labels as used.  */
   if (TREE_CODE (destination) == LABEL_DECL)
     TREE_USED (destination) = 1;
-    
-  if (TREE_CODE (destination) != LABEL_DECL)
-    /* We don't inline calls to functions with computed gotos.
-       Those functions are typically up to some funny business,
-       and may be depending on the labels being at particular
-       addresses, or some such.  */
-    DECL_UNINLINABLE (current_function_decl) = 1;
+  else
+    {
+      /* The DESTINATION is being used as an rvalue.  */
+      if (!processing_template_decl)
+       destination = decay_conversion (destination);
+      /* We don't inline calls to functions with computed gotos.
+        Those functions are typically up to some funny business,
+        and may be depending on the labels being at particular
+        addresses, or some such.  */
+      DECL_UNINLINABLE (current_function_decl) = 1;
+    }
   
   check_goto (destination);
 
index ea39a5d6cacfb50b2fffe3eb60e15dae47576eb3..7b983d8e743b8da0f4b83df332834d459b9faf21 100644 (file)
@@ -1,3 +1,9 @@
+2003-08-29  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/6196
+       * g++.dg/ext/label1.C: New test.
+       * g++.dg/ext/label2.C: Likewise.
+
 2003-08-28  Mark Mitchell  <mark@codesourcery.com>
 
        * g++.dg/expr/cond3.C: New test.
diff --git a/gcc/testsuite/g++.dg/ext/label1.C b/gcc/testsuite/g++.dg/ext/label1.C
new file mode 100644 (file)
index 0000000..8c6684d
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-options "" }
+
+int main(void) {
+  static const void* lbls[2][2] = {{&&lbl0, &&lbl0}, {&&lbl0, &&lbl0}};
+  goto *lbls[0];
+ lbl0:
+  ;
+}
diff --git a/gcc/testsuite/g++.dg/ext/label2.C b/gcc/testsuite/g++.dg/ext/label2.C
new file mode 100644 (file)
index 0000000..1b66f60
--- /dev/null
@@ -0,0 +1,11 @@
+// { dg-options "" }
+
+template <typename T>
+void f() {
+ l:
+  void *p[] = { &&l };
+
+  goto *p;
+}
+
+template void f<int>();