From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21668 invoked by alias); 22 Jun 2006 12:07:44 -0000 Received: (qmail 21650 invoked by uid 22791); 22 Jun 2006 12:07:43 -0000 X-Spam-Check-By: sourceware.org Received: from ms-1.rz.RWTH-Aachen.DE (HELO ms-dienst.rz.rwth-aachen.de) (134.130.3.130) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 22 Jun 2006 12:07:41 +0000 Received: from r220-1 (r220-1.rz.RWTH-Aachen.DE [134.130.3.31]) by ms-dienst.rz.rwth-aachen.de (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTP id <0J1900LI7G9GGB@ms-dienst.rz.rwth-aachen.de>; Thu, 22 Jun 2006 14:05:41 +0200 (MEST) Received: from relay.rwth-aachen.de ([134.130.3.1]) by r220-1 (MailMonitor for SMTP v1.2.2 ) ; Thu, 22 Jun 2006 14:05:39 +0200 (MEST) Received: from numa-vi (numa-vi.igpm.RWTH-Aachen.DE [134.130.161.247]) by relay.rwth-aachen.de (8.13.7/8.13.3/1) with ESMTP id k5MC5c81020477; Thu, 22 Jun 2006 14:05:38 +0200 (MEST) Date: Thu, 22 Jun 2006 12:07:00 -0000 From: Volker Reichelt Subject: [patch] Fix PR c++/java 11006: ICE on missing class$ To: gcc-patches@gcc.gnu.org, java-patches@gcc.gnu.org Message-id: MIME-version: 1.0 Content-type: TEXT/PLAIN; CHARSET=us-ascii Content-transfer-encoding: 7BIT Content-disposition: INLINE Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org X-SW-Source: 2006-q2/txt/msg00463.txt.bz2 In build_java_class_ref in cp/init.c we have if (jclass_node == NULL_TREE) fatal_error ("call to Java constructor, while % undefined"); and if (!field) internal_error ("can't find class$"); Is there are reason why we don't emit a regular error and return error_mark_node in these cases? Both conditions can be triggered with user errors (see testcases below) and should be treated as regular errors IMHO. See also PR 11006, PR 11468. =============================== extern "Java" { struct A {}; } typedef void* jclass; A* p = new A; =============================== bug.cc:8: internal compiler error: can't find class$ Please submit a full bug report, [etc.] =============================== extern "Java" { struct A {}; } A* p = new A; =============================== bug.cc:6: fatal error: call to Java constructor, while 'jclass' undefined compilation terminated. Bootstrapped and regtested on x86_64-unknown-linux-gnu. Ok for mainline? Regards, Volker :ADDPATCH C++: 2006-06-22 Volker Reichelt PR c++/11006 * init.c (build_new_1): Handle error_mark_nodes returned by build_java_class_ref. (build_java_class_ref): Do not abort compilation, but return error_mark_node. Improve error message. Fix indentation. =================================================================== --- gcc/gcc/cp/init.c (revision 114838) +++ gcc/gcc/cp/init.c (working copy) @@ -1696,6 +1696,9 @@ build_new_1 (tree placement, tree type, tree class_decl = build_java_class_ref (elt_type); static const char alloc_name[] = "_Jv_AllocObject"; + if (class_decl == error_mark_node) + return error_mark_node; + use_java_new = 1; if (!get_global_value_if_present (get_identifier (alloc_name), &alloc_fn)) @@ -2148,8 +2151,10 @@ build_java_class_ref (tree type) { jclass_node = IDENTIFIER_GLOBAL_VALUE (get_identifier ("jclass")); if (jclass_node == NULL_TREE) - fatal_error ("call to Java constructor, while % undefined"); - + { + error ("call to Java constructor, while % undefined"); + return error_mark_node; + } jclass_node = TREE_TYPE (jclass_node); } @@ -2164,8 +2169,11 @@ build_java_class_ref (tree type) break; } if (!field) - internal_error ("can't find class$"); - } + { + error ("can't find % in %qT", type); + return error_mark_node; + } + } class_decl = IDENTIFIER_GLOBAL_VALUE (name); if (class_decl == NULL_TREE) =================================================================== 2006-06-22 Volker Reichelt PR c++/11006 * g++.dg/other/java2.C: New test. =================================================================== --- gcc/gcc/testsuite/g++.dg/other/java2.C 2005-08-29 00:25:44 +0200 +++ gcc/gcc/testsuite/g++.dg/other/java2.C 2006-06-21 14:30:04 +0200 @@ -0,0 +1,11 @@ +// PR c++/??? +// { dg-do compile } + +extern "Java" +{ + struct A {}; +} + +typedef void* jclass; + +A* p = new A; // { dg-error "class\\$" } ===================================================================