]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c/86869 - preserve address-space info when building qualified ARRAY_TYPE
authorRichard Biener <rguenther@suse.de>
Mon, 4 Dec 2023 12:31:35 +0000 (13:31 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 5 Dec 2023 07:27:36 +0000 (08:27 +0100)
The following adjusts the C FE specific qualified type building
to preserve address-space info also for ARRAY_TYPE.

PR c/86869
gcc/c/
* c-typeck.cc (c_build_qualified_type): Preserve address-space
info for ARRAY_TYPE.

gcc/testsuite/
* gcc.target/avr/pr86869.c: New testcase.

gcc/c/c-typeck.cc
gcc/testsuite/gcc.target/avr/pr86869.c [new file with mode: 0644]

index a6edbc85f1096ed309b4523faddeb2c3aabd41ab..836893905fa039bb0cc4cd6cbcdadfcf5e68e66b 100644 (file)
@@ -16263,6 +16263,7 @@ c_build_qualified_type (tree type, int type_quals, tree orig_qual_type,
 
          t = build_variant_type_copy (type);
          TREE_TYPE (t) = element_type;
+         TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (element_type);
 
           if (TYPE_STRUCTURAL_EQUALITY_P (element_type)
               || (domain && TYPE_STRUCTURAL_EQUALITY_P (domain)))
diff --git a/gcc/testsuite/gcc.target/avr/pr86869.c b/gcc/testsuite/gcc.target/avr/pr86869.c
new file mode 100644 (file)
index 0000000..fbfb378
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+struct S {
+  char y[2];
+};
+
+void foo(const __memx  struct S *s) {
+  const char (*p)[2] = &s->y;
+}