public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c/86869 - preserve address-space info when building qualified ARRAY_TYPE
@ 2023-12-04 12:34 Richard Biener
  2023-12-04 21:14 ` Joseph Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2023-12-04 12:34 UTC (permalink / raw)
  To: gcc-patches; +Cc: Joseph S. Myers

The following adjusts the C FE specific qualified type building
to preserve address-space info also for ARRAY_TYPE.

Bootstrap / regtest running on x86_64-unknown-linux-gnu, OK?

Thanks,
Richard.

	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                      | 1 +
 gcc/testsuite/gcc.target/avr/pr86869.c | 9 +++++++++
 2 files changed, 10 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/avr/pr86869.c

diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index a6edbc85f10..836893905fa 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -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
index 00000000000..fbfb378e8c9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/pr86869.c
@@ -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;
+}
-- 
2.35.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] c/86869 - preserve address-space info when building qualified ARRAY_TYPE
  2023-12-04 12:34 [PATCH] c/86869 - preserve address-space info when building qualified ARRAY_TYPE Richard Biener
@ 2023-12-04 21:14 ` Joseph Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2023-12-04 21:14 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Mon, 4 Dec 2023, Richard Biener wrote:

> The following adjusts the C FE specific qualified type building
> to preserve address-space info also for ARRAY_TYPE.
> 
> Bootstrap / regtest running on x86_64-unknown-linux-gnu, OK?

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-04 21:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-04 12:34 [PATCH] c/86869 - preserve address-space info when building qualified ARRAY_TYPE Richard Biener
2023-12-04 21:14 ` Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).