Commit dd125026 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/70267 (ICE on invalid code at -O1 and above on x86_64-linux-gnu in…

re PR c++/70267 (ICE on invalid code at -O1 and above on x86_64-linux-gnu in propagate_necessity, at tree-ssa-dce.c:924)

	PR c++/70267
	* 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.

From-SVN: r234319
parent a065dbc9
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
......
......@@ -2872,6 +2872,14 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
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
......
// 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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment