Bug 17401 - [3.4/4.0 Regression] ICE with invalid pure specifier
Summary: [3.4/4.0 Regression] ICE with invalid pure specifier
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Giovanni Bajo
URL:
Keywords: ice-checking, ice-on-invalid-code
: 21252 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-09-10 15:53 UTC by Steven Bosscher
Modified: 2005-04-27 14:54 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.5
Known to fail: 4.0.0 3.4.3
Last reconfirmed: 2004-09-10 18:40:08


Attachments
Test case for this bug (206.68 KB, application/x-gzip)
2004-09-10 15:53 UTC, Steven Bosscher
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Bosscher 2004-09-10 15:53:09 UTC
The attached test case ICEs during parsing with checking enabled: 
 
$ g++ t.ii 
t.ii:52482: internal compiler error: tree check: expected identifier_node, 
have integer_cst in c_parse_error, at c-common.c:5490
Comment 1 Steven Bosscher 2004-09-10 15:53:40 UTC
Created attachment 7087 [details]
Test case for this bug
Comment 2 Serge Belyshev 2004-09-10 18:40:06 UTC
// "minimized" testcase :-)

class foo { virtual void bar () = __null; };
Comment 3 Wolfgang Bangerth 2004-09-10 18:46:15 UTC
:-) I think I saw Mark submit a patch maybe a year ago that really 
required the token "0" to indicate that a function is abstract. I 
have a hard time understanding why anyone would use anything different 
anyway, but that may be beyond the point... 
 
W. 
Comment 4 Andrew Pinski 2004-09-10 22:25:17 UTC
: Search converges between 2003-12-17-trunk (#430) and 2003-12-18-trunk (#431).
Hmm that is the normal date for this ICE :)
This only happens with checking turned also.
Comment 5 Giovanni Bajo 2004-09-10 23:52:26 UTC
Anybody has an --enable-checking version of 3.4? I assume the bug is present 
also there.
Comment 6 Giovanni Bajo 2004-09-11 00:33:34 UTC
Mine.
Comment 7 Giovanni Bajo 2004-09-11 13:09:10 UTC
Patch posted:
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01085.html
Comment 8 Wolfgang Bangerth 2004-09-12 22:46:00 UTC
Giovanni's right: it also ICEs with an --enable-checking'd 3.4: 
 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc 
x.cc:1: internal compiler error: tree check: expected identifier_node, have 
integer_cst in c_parse_error, at c-common.c:5893 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
Giovanni, you may want to apply your patch there as well. 
 
W. 
Comment 9 Steven Bosscher 2004-09-19 12:21:52 UTC
Isn't this just a matter of not filling ridpointers with null_node 
as done below?  Whenever RID_NULL is encountered, we return just 
null_node anyway, and there are apparently no other places where 
ridpointers[RID_NULL] is read.  I'll test this patch, let's see if 
this helps. 
 
Index: lex.c 
=================================================================== 
RCS file: /cvs/gcc/gcc/gcc/cp/lex.c,v 
retrieving revision 1.343 
diff -c -3 -p -r1.343 lex.c 
*** lex.c       9 Sep 2004 17:11:18 -0000       1.343 
--- lex.c       19 Sep 2004 12:20:27 -0000 
*************** cxx_init (void) 
*** 358,364 **** 
       not shared. */ 
    null_node = make_node (INTEGER_CST); 
    TREE_TYPE (null_node) = c_common_type_for_size (POINTER_SIZE, 0); 
-   ridpointers[RID_NULL] = null_node; 
 
    interface_unknown = 1; 
 
--- 358,363 ---- 
Comment 10 Giovanni Bajo 2004-09-19 12:41:25 UTC
Subject: Re:  [3.4/4.0 Regression] ICE with invalid pure specifier

steven at gcc dot gnu dot org wrote:

> Isn't this just a matter of not filling
> ridpointers with null_node as done below?  Whenever RID_NULL
> is encountered, we return just
> null_node anyway, and there are apparently no other places where
> ridpointers[RID_NULL] is read.  I'll test this patch, let's see if
> this helps.

Maybe. But cp_parser_error is stil buggy and will ICE on other keywords (e.g.
"public"/"protected"/"private") so thinking that is still desirable anyway.
I'll get back to this bug later next week when I'm through with the finals.

Giovanni Bajo


Comment 11 Giovanni Bajo 2004-09-19 12:45:18 UTC
(In reply to comment #10)

> "public"/"protected"/"private") so thinking that is still desirable anyway.
                                     ^^^^^^^^

"fixing"
Comment 12 Giovanni Bajo 2004-09-27 12:05:30 UTC
Patch needs update and splitting. The hunks to cp_parser_pure_specifier and to 
decl.c are safe and can be submitted separately as a way to improve/fix the 
error message here.
The patch to cp_parser_error requires to be rewritten by taking into account 
how each keywords is identified in source code.
Comment 13 Mark Mitchell 2004-12-23 22:20:14 UTC
The cp_parser_pure_specifier and decl2.c hunks are OK, and I think will be
sufficient to fix the PR.  Please apply.
Comment 14 Andrew Pinski 2005-01-06 22:57:30 UTC
I tested this again and seems fixed on the mainline, is there a reason why it is still marked as 4.0 
regression?
Comment 15 Andrew Pinski 2005-01-25 19:14:14 UTC
Is this fixed or just keeping open for a reason?
Comment 16 Giovanni Bajo 2005-02-03 00:54:29 UTC
Ah, I had forgot about this. Let me retest the approved parts of the patch and 
apply it.
Comment 17 GCC Commits 2005-02-03 10:26:46 UTC
Subject: Bug 17401

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	giovannibajo@gcc.gnu.org	2005-02-03 10:26:23

Modified files:
	gcc/cp         : ChangeLog parser.c decl2.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: error25.C 

Log message:
	PR c++/17401
	* parser.c (cp_parser_pure_specifier): Emit a specific error
	message with an invalid pure specifier.
	* decl2.c (grok_function_init): Remove.
	(grokfield): An initializer for a method is a always a pure
	specifier.
	
	PR c++/17401
	* g++.dg/parse/error25.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4614&r2=1.4615
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.310&r2=1.311
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.764&r2=1.765
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4992&r2=1.4993
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error25.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 18 Giovanni Bajo 2005-02-03 10:29:06 UTC
I have fixed the diagnostic issue as well. I don't see anything else in this PR 
which is worth a regression, so I'm closing it.
Comment 19 Andrew Pinski 2005-04-27 14:54:29 UTC
*** Bug 21252 has been marked as a duplicate of this bug. ***