This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/43070 (ICE on computed goto)


For some reason, execute_update_addresses_taken was clearing TREE_ADDRESSABLE on the array, and then we complained that it wasn't set anymore. But the real issue here is that the testcase is invalid, and we were failing to diagnose it: both label[12].C are trying to goto the address of the array, rather than the element.

I guess when Mark was fixing c++/6196 he didn't notice that the testcase was ill-formed, and just made the compiler accept it. The fact that we don't have an INDIRECT_REF for the * in the computed goto syntax was confusing me for a bit, too. In any case, this patch adjusts the testcases to expect errors, and reverts part of that patch.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 2e4ad5f43180b2c803f61baff31b6cc929d293b3
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Feb 18 12:38:13 2010 -0500

    	PR c++/43070
    	* semantics.c (finish_goto_stmt): Don't call decay_conversion.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 24390d9..5d8b767 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -546,10 +546,8 @@ finish_goto_stmt (tree destination)
     TREE_USED (destination) = 1;
   else
     {
-      /* The DESTINATION is being used as an rvalue.  */
       if (!processing_template_decl)
 	{
-	  destination = decay_conversion (destination);
 	  destination = cp_convert (ptr_type_node, destination);
 	  if (error_operand_p (destination))
 	    return NULL_TREE;
diff --git a/gcc/testsuite/g++.dg/ext/label1.C b/gcc/testsuite/g++.dg/ext/label1.C
index 8c6684d..95fd644 100644
--- a/gcc/testsuite/g++.dg/ext/label1.C
+++ b/gcc/testsuite/g++.dg/ext/label1.C
@@ -2,7 +2,9 @@
 
 int main(void) {
   static const void* lbls[2][2] = {{&&lbl0, &&lbl0}, {&&lbl0, &&lbl0}};
-  goto *lbls[0];
+  goto *lbls[0][0];
+  goto *lbls[0][0][0];		// { dg-message "" }
+  goto *lbls[0];		// { dg-error "" }
  lbl0:
   ;
 }
diff --git a/gcc/testsuite/g++.dg/ext/label2.C b/gcc/testsuite/g++.dg/ext/label2.C
index 1b66f60..7d11d00 100644
--- a/gcc/testsuite/g++.dg/ext/label2.C
+++ b/gcc/testsuite/g++.dg/ext/label2.C
@@ -5,7 +5,7 @@ void f() {
  l:
   void *p[] = { &&l };
 
-  goto *p;
+  goto *p[0];
 }
 
 template void f<int>();

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]