re PR c++/44561 (using nullptr_t with -flto/-fwhopr causes ICE: tree code 'lang_type' is not supported in gimple streams)

2010-10-14  Richard Guenther  <rguenther@suse.de>

	PR lto/44561
	* tree.def (NULLPTR_TYPE): New tree code.
	* dbxout.c (dbxout_type): Handle NULLPTR_TYPE.
	* dwarf2out.c (is_base_type): Likewise.
	(gen_type_die_with_usage): Likewise.
	* sdbout.c (plain_type_1): Likewise.
	* tree.c (build_int_cst_wide): Likewise.
	* gimple.c (gimple_types_compatible_p_1): NULLPTR_TYPE types
	are equal.

	cp/
	* cp-tree.h (NULLPTR_TYPE_P): Adjust.
	* decl.c (cxx_init_decl_processing): Build a NULLPTR_TYPE node,
	use build_int_cst.
	* error.c (dump_type): Handle NULLPTR_TYPE.
	(dump_type_prefix): Likewise.
	(dump_type_suffix): Likewise.
	* mangle.c (write_type): Likewise.
	* name-lookup.c (arg_assoc_type): Likewise.
	* rtti.c (typeinfo_in_lib_p): Likewise.
	* pt.c (tsubst): Likewise.

	* g++.dg/lto/20101010-3_0.C: New testcase.
	* g++.dg/lto/20101010-4_0.C: Likewise.

From-SVN: r165462
This commit is contained in:
Richard Guenther 2010-10-14 11:59:47 +00:00 committed by Richard Biener
parent a16ced220f
commit 1e85e7204d
18 changed files with 83 additions and 20 deletions

View File

@ -1,3 +1,15 @@
2010-10-14 Richard Guenther <rguenther@suse.de>
PR lto/44561
* tree.def (NULLPTR_TYPE): New tree code.
* dbxout.c (dbxout_type): Handle NULLPTR_TYPE.
* dwarf2out.c (is_base_type): Likewise.
(gen_type_die_with_usage): Likewise.
* sdbout.c (plain_type_1): Likewise.
* tree.c (build_int_cst_wide): Likewise.
* gimple.c (gimple_types_compatible_p_1): NULLPTR_TYPE types
are equal.
2010-10-14 Joseph Myers <joseph@codesourcery.com>
* params.c (params_finished): New.

View File

@ -1,3 +1,17 @@
2010-10-14 Richard Guenther <rguenther@suse.de>
PR lto/44561
* cp-tree.h (NULLPTR_TYPE_P): Adjust.
* decl.c (cxx_init_decl_processing): Build a NULLPTR_TYPE node,
use build_int_cst.
* error.c (dump_type): Handle NULLPTR_TYPE.
(dump_type_prefix): Likewise.
(dump_type_suffix): Likewise.
* mangle.c (write_type): Likewise.
* name-lookup.c (arg_assoc_type): Likewise.
* rtti.c (typeinfo_in_lib_p): Likewise.
* pt.c (tsubst): Likewise.
2010-10-13 Jason Merrill <jason@redhat.com>
PR c++/45984

View File

@ -3051,9 +3051,7 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
|| TREE_CODE (TYPE) == COMPLEX_TYPE)
/* True iff TYPE is cv decltype(nullptr). */
#define NULLPTR_TYPE_P(TYPE) \
(TREE_CODE (TYPE) == LANG_TYPE \
&& TYPE_MAIN_VARIANT (TYPE) == nullptr_type_node)
#define NULLPTR_TYPE_P(TYPE) (TREE_CODE (TYPE) == NULLPTR_TYPE)
/* [basic.types]

View File

@ -3552,15 +3552,14 @@ cxx_init_decl_processing (void)
global_delete_fndecl = push_cp_library_fn (DELETE_EXPR, deltype);
push_cp_library_fn (VEC_DELETE_EXPR, deltype);
nullptr_type_node = make_node (LANG_TYPE);
nullptr_type_node = make_node (NULLPTR_TYPE);
TYPE_SIZE (nullptr_type_node) = bitsize_int (GET_MODE_BITSIZE (ptr_mode));
TYPE_SIZE_UNIT (nullptr_type_node) = size_int (GET_MODE_SIZE (ptr_mode));
TYPE_UNSIGNED (nullptr_type_node) = 1;
TYPE_PRECISION (nullptr_type_node) = GET_MODE_BITSIZE (ptr_mode);
SET_TYPE_MODE (nullptr_type_node, Pmode);
record_builtin_type (RID_MAX, "decltype(nullptr)", nullptr_type_node);
nullptr_node = make_node (INTEGER_CST);
TREE_TYPE (nullptr_node) = nullptr_type_node;
nullptr_node = build_int_cst (nullptr_type_node, 0);
}
abort_fndecl

View File

@ -500,6 +500,10 @@ dump_type (tree t, int flags)
pp_cxx_right_paren (cxx_pp);
break;
case NULLPTR_TYPE:
pp_string (cxx_pp, "std::nullptr_t");
break;
default:
pp_unsupported_tree (cxx_pp, t);
/* Fall through to error. */
@ -728,6 +732,7 @@ dump_type_prefix (tree t, int flags)
case DECLTYPE_TYPE:
case TYPE_PACK_EXPANSION:
case FIXED_POINT_TYPE:
case NULLPTR_TYPE:
dump_type (t, flags);
pp_base (cxx_pp)->padding = pp_before;
break;
@ -830,6 +835,7 @@ dump_type_suffix (tree t, int flags)
case DECLTYPE_TYPE:
case TYPE_PACK_EXPANSION:
case FIXED_POINT_TYPE:
case NULLPTR_TYPE:
break;
default:

View File

@ -1943,17 +1943,16 @@ write_type (tree type)
write_char ('E');
break;
case NULLPTR_TYPE:
write_string ("Dn");
break;
case TYPEOF_TYPE:
sorry ("mangling typeof, use decltype instead");
break;
case LANG_TYPE:
if (NULLPTR_TYPE_P (type))
{
write_string ("Dn");
break;
}
/* else fall through. */
/* fall through. */
default:
gcc_unreachable ();

View File

@ -4932,6 +4932,7 @@ arg_assoc_type (struct arg_lookup *k, tree type)
case BOOLEAN_TYPE:
case FIXED_POINT_TYPE:
case DECLTYPE_TYPE:
case NULLPTR_TYPE:
return false;
case RECORD_TYPE:
if (TYPE_PTRMEMFUNC_P (type))
@ -4963,7 +4964,6 @@ arg_assoc_type (struct arg_lookup *k, tree type)
return false;
case LANG_TYPE:
gcc_assert (type == unknown_type_node
|| NULLPTR_TYPE_P (type)
|| type == init_list_type_node);
return false;
case TYPE_PACK_EXPANSION:

View File

@ -10097,6 +10097,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
case COMPLEX_TYPE:
case VECTOR_TYPE:
case BOOLEAN_TYPE:
case NULLPTR_TYPE:
case LANG_TYPE:
return t;

View File

@ -1051,12 +1051,11 @@ typeinfo_in_lib_p (tree type)
case BOOLEAN_TYPE:
case REAL_TYPE:
case VOID_TYPE:
case NULLPTR_TYPE:
return true;
case LANG_TYPE:
if (NULLPTR_TYPE_P (type))
return true;
/* else fall through. */
/* fall through. */
default:
return false;

View File

@ -1863,6 +1863,7 @@ dbxout_type (tree type, int full)
switch (TREE_CODE (type))
{
case VOID_TYPE:
case NULLPTR_TYPE:
case LANG_TYPE:
/* For a void type, just define it as itself; i.e., "5=5".
This makes us consider it defined

View File

@ -12611,6 +12611,7 @@ is_base_type (tree type)
case METHOD_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
case NULLPTR_TYPE:
case OFFSET_TYPE:
case LANG_TYPE:
case VECTOR_TYPE:
@ -20215,6 +20216,7 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
/* No DIEs needed for fundamental types. */
break;
case NULLPTR_TYPE:
case LANG_TYPE:
/* Just use DW_TAG_unspecified_type. */
{

View File

@ -3661,6 +3661,10 @@ gimple_types_compatible_p_1 (tree t1, tree t2, enum gtc_mode mode,
goto different_types;
}
case NULLPTR_TYPE:
/* There is only one decltype(nullptr). */
goto same_types;
case INTEGER_TYPE:
case BOOLEAN_TYPE:
{

View File

@ -495,6 +495,7 @@ plain_type_1 (tree type, int level)
switch (TREE_CODE (type))
{
case VOID_TYPE:
case NULLPTR_TYPE:
return T_VOID;
case BOOLEAN_TYPE:
case INTEGER_TYPE:

View File

@ -1,3 +1,9 @@
2010-10-14 Richard Guenther <rguenther@suse.de>
PR lto/44561
* g++.dg/lto/20101010-3_0.C: New testcase.
* g++.dg/lto/20101010-4_0.C: Likewise.
2010-10-14 Iain Sandoe <iains@gcc.gnu.org>
* objc.dg/pr45878.m: Update to include NSConstantString interface

View File

@ -0,0 +1,5 @@
// { dg-lto-do link }
// { dg-lto-options { "-flto -std=c++0x" } }
decltype(nullptr) a;
int main() { return 0; }

View File

@ -0,0 +1,9 @@
// { dg-lto-do link }
// { dg-lto-options { { -std=c++0x -flto -r -nostdlib } { -std=c++0x -flto -g -r -nostdlib } } }
typedef decltype(nullptr) nullptr_t;
class shared_ptr {
public:
shared_ptr(nullptr_t __p);
};
shared_ptr p = nullptr;

View File

@ -1178,6 +1178,10 @@ build_int_cst_wide (tree type, unsigned HOST_WIDE_INT low, HOST_WIDE_INT hi)
switch (TREE_CODE (type))
{
case NULLPTR_TYPE:
gcc_assert (hi == 0 && low == 0);
/* Fallthru. */
case POINTER_TYPE:
case REFERENCE_TYPE:
/* Cache NULL pointer. */

View File

@ -162,15 +162,18 @@ DEFTREECODE (REAL_TYPE, "real_type", tcc_type, 0)
The TREE_TYPE points to the node for the type pointed to. */
DEFTREECODE (POINTER_TYPE, "pointer_type", tcc_type, 0)
/* A reference is like a pointer except that it is coerced
automatically to the value it points to. Used in C++. */
DEFTREECODE (REFERENCE_TYPE, "reference_type", tcc_type, 0)
/* The C++ decltype(nullptr) type. */
DEFTREECODE (NULLPTR_TYPE, "nullptr_type", tcc_type, 0)
/* _Fract and _Accum types in Embedded-C. Different fixed-point types
are distinguished by machine mode and by the TYPE_SIZE and the
TYPE_PRECISION. */
DEFTREECODE (FIXED_POINT_TYPE, "fixed_point_type", tcc_type, 0)
/* A reference is like a pointer except that it is coerced
automatically to the value it points to. Used in C++. */
DEFTREECODE (REFERENCE_TYPE, "reference_type", tcc_type, 0)
/* The ordering of the following codes is optimized for the checking
macros in tree.h. Changing the order will degrade the speed of the
compiler. COMPLEX_TYPE, VECTOR_TYPE, ARRAY_TYPE. */