blob: 8fba6af3b8a1e13defaf62bfb0f10a8af41ee2c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
From b58a503c5dbde32cbb9bd48ea16ff868d2023cf9 Mon Sep 17 00:00:00 2001
From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 12 Apr 2011 06:53:13 +0000
Subject: [PATCH 106/200] PR c/48517
* c-typeck.c (store_init_value): Set TREE_TYPE (decl) to
qualified type.
* gcc.c-torture/compile/pr48517.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172300 138bc75d-0d04-0410-961f-82ee72b054a4
index a22bb73..fca369c 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));
}
}
}
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);
+}
--
1.7.0.4
|