summaryrefslogtreecommitdiff
blob: 1d23b1c2e38b8a28eefa25b78443c261b96194f5 (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
52
53
54
55
56
57
58
59
60
61
2000-10-25  Jakub Jelinek  <jakub@redhat.com>

	* stor-layout.c (layout_type): If TYPE_ALIAS_SET was already set on the
	incomplete type force it into alias set 0.

	* gcc.c-torture/execute/20001024-1.c: New test.

--- gcc/testsuite/gcc.c-torture/execute/20001024-1.c.jj	Tue Oct 24 13:32:08 2000
+++ gcc/testsuite/gcc.c-torture/execute/20001024-1.c	Tue Oct 24 10:16:57 2000
@@ -0,0 +1,34 @@
+struct a;
+
+extern int baz (struct a *__restrict x);
+
+struct a {
+  long v;
+  long w;
+};
+
+struct b {
+  struct a c;
+  struct a d;
+};
+
+int bar (int x, const struct b *__restrict y, struct b *__restrict z)
+{
+  if (y->c.v || y->c.w != 250000 || y->d.v || y->d.w != 250000)
+    abort();
+}
+
+void foo(void)
+{
+  struct b x;
+  x.c.v = 0;
+  x.c.w = 250000;
+  x.d = x.c;
+  bar(0, &x, ((void *)0));
+}
+
+int main()
+{
+  foo();
+  exit(0);
+}
--- gcc/stor-layout.c.jj	Mon Oct 23 15:24:47 2000
+++ gcc/stor-layout.c	Wed Oct 25 10:46:57 2000
@@ -1507,6 +1507,14 @@ layout_type (type)
      record it so set_sizetype can fix it up.  */
   if (! sizetype_set)
     early_type_list = tree_cons (NULL_TREE, type, early_type_list);
+
+  /* If an alias set has been set for this aggregate when it was incomplete,
+     force it into alias set 0.
+     This is too conservative, but we cannot call record_component_aliases
+     here because some frontends still change the aggregates after
+     layout_type.  */
+  if (AGGREGATE_TYPE_P (type) && TYPE_ALIAS_SET_KNOWN_P (type))
+    TYPE_ALIAS_SET (type) = 0;
 }
 
 /* Create and return a type for signed integers of PRECISION bits.  */