* init.c (build_new_1): Complain and return error_mark_node
if alloc_fn is not _Jv_AllocObject function returning pointer.
* g++.dg/ext/java-3.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234319
138bc75d-0d04-0410-961f-
82ee72b054a4
+2016-03-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/70267
+ * init.c (build_new_1): Complain and return error_mark_node
+ if alloc_fn is not _Jv_AllocObject function returning pointer.
+
2016-03-18 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/70205
return error_mark_node;
}
alloc_fn = OVL_CURRENT (alloc_fn);
+ if (TREE_CODE (alloc_fn) != FUNCTION_DECL
+ || TREE_CODE (TREE_TYPE (alloc_fn)) != FUNCTION_TYPE
+ || !POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (alloc_fn))))
+ {
+ if (complain & tf_error)
+ error ("%qD is not a function returning a pointer", alloc_fn);
+ return error_mark_node;
+ }
class_addr = build1 (ADDR_EXPR, jclass_node, class_decl);
alloc_call = cp_build_function_call_nary (alloc_fn, complain,
class_addr, NULL_TREE);
+2016-03-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/70267
+ * g++.dg/ext/java-3.C: New test.
+
2016-03-18 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/70205
--- /dev/null
+// PR c++/70267
+// { dg-do compile }
+// { dg-options "-O2" }
+
+extern "Java"
+{
+ typedef __java_int jint;
+ namespace java
+ {
+ namespace lang
+ {
+ class Class;
+ class Object;
+ class Throwable {};
+ class Foo;
+ }
+ }
+}
+
+typedef struct java::lang::Object * jobject;
+typedef struct java::lang::Throwable * jthrowable;
+typedef class java::lang::Class * jclass;
+
+using java::lang::Foo;
+
+class Foo: public java::lang::Throwable
+{
+ public:static::java::lang::Class class$;
+};
+
+extern "C" Foo _Jv_AllocObject (jclass);
+extern "C" void _Jv_Throw (jthrowable) __attribute__ ((__noreturn__));
+
+void
+Bar4 (void)
+{
+ Foo * f = new java::lang::Foo; // { dg-error "is not a function returning a pointer" }
+ throw (f);
+}