public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Fix PR c++/java 11006: ICE on missing class$
@ 2006-06-22 12:07 Volker Reichelt
  2006-06-22 12:11 ` Andrew Haley
  0 siblings, 1 reply; 3+ messages in thread
From: Volker Reichelt @ 2006-06-22 12:07 UTC (permalink / raw)
  To: gcc-patches, java-patches

In build_java_class_ref in cp/init.c we have

  if (jclass_node == NULL_TREE)
    fatal_error ("call to Java constructor, while %<jclass%> 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  <reichelt@igpm.rwth-aachen.de>

	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 %<jclass%> undefined");
-
+	{
+	  error ("call to Java constructor, while %<jclass%> 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 %<class$%> in %qT", type);
+	return error_mark_node;
+      }
+  }
 
   class_decl = IDENTIFIER_GLOBAL_VALUE (name);
   if (class_decl == NULL_TREE)
===================================================================

2006-06-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	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\\$" }
===================================================================


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] Fix PR c++/java 11006: ICE on missing class$
  2006-06-22 12:07 [patch] Fix PR c++/java 11006: ICE on missing class$ Volker Reichelt
@ 2006-06-22 12:11 ` Andrew Haley
  2006-06-22 14:53   ` Mark Mitchell
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Haley @ 2006-06-22 12:11 UTC (permalink / raw)
  To: Volker Reichelt; +Cc: gcc-patches, java-patches

Volker Reichelt writes:
 > In build_java_class_ref in cp/init.c we have
 > 
 >   if (jclass_node == NULL_TREE)
 >     fatal_error ("call to Java constructor, while %<jclass%> 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.

That seems reasonable to me.

Andrew.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] Fix PR c++/java 11006: ICE on missing class$
  2006-06-22 12:11 ` Andrew Haley
@ 2006-06-22 14:53   ` Mark Mitchell
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Mitchell @ 2006-06-22 14:53 UTC (permalink / raw)
  To: Andrew Haley; +Cc: Volker Reichelt, gcc-patches, java-patches

Andrew Haley wrote:
> Volker Reichelt writes:
>  > In build_java_class_ref in cp/init.c we have
>  > 
>  >   if (jclass_node == NULL_TREE)
>  >     fatal_error ("call to Java constructor, while %<jclass%> 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.
> 
> That seems reasonable to me.

Me too.  That change is pre-approved.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-06-22 14:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-22 12:07 [patch] Fix PR c++/java 11006: ICE on missing class$ Volker Reichelt
2006-06-22 12:11 ` Andrew Haley
2006-06-22 14:53   ` Mark Mitchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).