Commit e30ecc5d by Jakub Jelinek

re PR c/48517 (ICE in build_unary_op, at c-typeck.c:3786)

	PR c/48517
	* c-typeck.c (store_init_value): Set TREE_TYPE (decl) to
	qualified type.

	* gcc.c-torture/compile/pr48517.c: New test.

From-SVN: r172299
parent bae5cddf
...@@ -5773,11 +5773,13 @@ store_init_value (location_t init_loc, tree decl, tree init, tree origtype) ...@@ -5773,11 +5773,13 @@ store_init_value (location_t init_loc, tree decl, tree init, tree origtype)
/* For int foo[] = (int [3]){1}; we need to set array size /* For int foo[] = (int [3]){1}; we need to set array size
now since later on array initializer will be just the now since later on array initializer will be just the
brace enclosed list of the compound literal. */ brace enclosed list of the compound literal. */
tree etype = strip_array_types (TREE_TYPE (decl));
type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type)); type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
TREE_TYPE (decl) = type;
TYPE_DOMAIN (type) = TYPE_DOMAIN (TREE_TYPE (cldecl)); TYPE_DOMAIN (type) = TYPE_DOMAIN (TREE_TYPE (cldecl));
layout_type (type); layout_type (type);
layout_decl (cldecl, 0); layout_decl (cldecl, 0);
TREE_TYPE (decl)
= c_build_qualified_type (type, TYPE_QUALS (etype));
} }
} }
} }
......
/* PR c/48517 */
/* { dg-do compile } */
/* { dg-options "" } */
void bar (const unsigned short *);
void
foo (void)
{
static const unsigned short array[] = (const unsigned short []) { 0x0D2B };
const unsigned short *ptr = array;
bar (ptr);
}
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