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]

Re: ICE in 20000410



  I think I submitted it already for an earlier snapshot, but just to be
  sure here it goes again:

  $ cat 00.cc
  template <typename T>
  class C {
	  static int const N (1000);
  };

That code is invalid.  This patch fixes g++ to issue an appropriate
error message.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2000-04-17  Mark Mitchell  <mark@codesourcery.com>

	* decl2.c (grokfield): Issue error on illegal data member
	declaration.

Index: decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.334
diff -c -p -r1.334 decl2.c
*** decl2.c	2000/04/15 19:54:26	1.334
--- decl2.c	2000/04/18 01:20:16
*************** grokfield (declarator, declspecs, init, 
*** 1572,1578 ****
  	  || TREE_CODE (TREE_OPERAND (declarator, 0)) == SCOPE_REF)
        && parmlist_is_exprlist (CALL_DECLARATOR_PARMS (declarator)))
      {
!       init = TREE_OPERAND (declarator, 1);
        declarator = TREE_OPERAND (declarator, 0);
        flags = 0;
      }
--- 1572,1594 ----
  	  || TREE_CODE (TREE_OPERAND (declarator, 0)) == SCOPE_REF)
        && parmlist_is_exprlist (CALL_DECLARATOR_PARMS (declarator)))
      {
!       /* It's invalid to try to initialize a data member using a
! 	 functional notation, e.g.:
! 	 
!             struct S {
! 	      static int i (3);
! 	    };
! 	    
! 	 Explain that to the user.  */
!       static int explained_p;
! 
!       cp_error ("invalid data member initiailization");
!       if (!explained_p)
! 	{
! 	  cp_error ("use `=' to initialize static data members");
! 	  explained_p = 1;
! 	}
! 
        declarator = TREE_OPERAND (declarator, 0);
        flags = 0;
      }
Index: testsuite/g++.old-deja/g++.other/crash17.C
===================================================================
RCS file: crash17.C
diff -N crash17.C
*** /dev/null	Tue May  5 13:32:27 1998
--- crash17.C	Mon Apr 17 18:21:42 2000
***************
*** 0 ****
--- 1,6 ----
+ // Build don't link:
+ // Origin: Dima Volodin <dvv@dvv.org>
+ 
+ class C {
+   static int const N (1000);
+ };

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