This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: ICE in 20000410
- To: dvv at dvv dot org
- Subject: Re: ICE in 20000410
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Mon, 17 Apr 2000 18:32:39 -0700
- Cc: gcc-bugs at gcc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <38FB3C32.9783A254@dvv.org>
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);
+ };