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: partially PR c++/17401


Hi,

As Giovanni points out in the audit trail, this only fixes the part
of the bug where "__null" has to be printed, not other cases where
ridpointers[id] does not point to an identifier node.

It is quite beyond me why anyone would put non-identifier tree nodes
in the ridpointer array - fortunately this is only done for a small
number of keywords.  Like "__null" without this patch.
This leads to an ICE in c_parse_error when it thinks it can print a
CCP_NAME but the token value turns out to be a tree for an integer
constant.  The ICE comes from tree checking.    The test case for
the ICE is this:

class foo { virtual void bar () = __null; };

Fortunately we never actually read ridpointers[RID_NULL] except for
error reporting, so it is safe to just leave the identifier node
"__null" (which is created in "init_reswords" (which should really
be static to lex.c, btw).

This patch only squelches the ICE.  The diagnostic g++ now gives is
still not very helpful:
t.cc:1: error: expected `0' before "__null"
t.cc:1: error: invalid initializer for virtual method `virtual void foo::bar()'
t.cc:1: error: expected `;' before "__null"

But this is not as bad as the ICE...

Bootstrapped and tested on x86_64-suse-linux-gnu, OK?

Gr.
Steven


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 ---- 


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