This is the mail archive of the gcc-bugs@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]

PATCH for Re: labels don't work in template functions



>>>>> "Gerald" == Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> writes:

    Gerald> (At least) today's CVS snapshot breaks the following code:

    Gerald> -------- snipedee -------- template<class T> void
    Gerald> compute(T) { goto Exit; Exit: ; }

    Gerald> main() { compute(0); } -------- snipedee --------

Here's a fix.  Jason?

-- 
Mark Mitchell <mmitchell@usa.net>
http://home.earthlink.net/~mbmitchell
Consulting Services Available

Tue Mar 24 11:25:30 1998  Mark Mitchell  <mmitchell@usa.net>

	* pt.c (tsubst_expr): Handle GOTO_STMT correctly.

Index: cp/pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.104
diff -c -p -r1.104 pt.c
*** pt.c	1998/03/24 10:25:40	1.104
--- pt.c	1998/03/24 19:23:52
*************** tsubst_expr (t, args, in_decl)
*** 5077,5084 ****
  
      case GOTO_STMT:
        lineno = TREE_COMPLEXITY (t);
!       finish_goto_stmt (tsubst_expr (GOTO_DESTINATION (t),
! 				     args, in_decl));
        break;
  
      case ASM_STMT:
--- 5082,5094 ----
  
      case GOTO_STMT:
        lineno = TREE_COMPLEXITY (t);
!       t = GOTO_DESTINATION (t);
!       if (TREE_CODE (t) != IDENTIFIER_NODE)
! 	/* Computed goto's must be tsubst'd into.  On the other hand,
! 	   non-computed gotos must not be; the identifier in question
! 	   will have no binding.  */
! 	t = tsubst_expr (t, args, in_decl);
!       finish_goto_stmt (t);
        break;
  
      case ASM_STMT:
Index: testsuite/g++.old-deja/g++.pt/goto.C
===================================================================
RCS file: goto.C
diff -N goto.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- goto.C	Tue Mar 24 11:23:52 1998
***************
*** 0 ****
--- 1,12 ----
+ // Build don't link:
+ 
+ template<class T>
+ void compute(T) {
+     goto Exit;
+ Exit: ;
+     }
+ 
+ int main() 
+ {
+   compute(0);
+ }


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