diff options
author | Jakub Jelinek <jakub@gcc.gnu.org> | 2011-04-12 08:43:12 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2011-04-12 08:43:12 +0200 |
commit | e30ecc5d62d3fb4dcb02174702407799fb3f1c64 (patch) | |
tree | 82fc95409c02251ff92e0134aaf36745e161820e /gcc | |
parent | bae5cddff8b905bb49ed4e013e9756ebea13c099 (diff) | |
download | gcc-e30ecc5d62d3fb4dcb02174702407799fb3f1c64.zip gcc-e30ecc5d62d3fb4dcb02174702407799fb3f1c64.tar.gz gcc-e30ecc5d62d3fb4dcb02174702407799fb3f1c64.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-typeck.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr48517.c | 13 |
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index c386f56..15b7755 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -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 now since later on array initializer will be just the brace enclosed list of the compound literal. */ + tree etype = strip_array_types (TREE_TYPE (decl)); type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type)); - TREE_TYPE (decl) = type; TYPE_DOMAIN (type) = TYPE_DOMAIN (TREE_TYPE (cldecl)); layout_type (type); layout_decl (cldecl, 0); + TREE_TYPE (decl) + = c_build_qualified_type (type, TYPE_QUALS (etype)); } } } diff --git a/gcc/testsuite/gcc.c-torture/compile/pr48517.c b/gcc/testsuite/gcc.c-torture/compile/pr48517.c new file mode 100644 index 0000000..30b3ecb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr48517.c @@ -0,0 +1,13 @@ +/* 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); +} |