public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-6134] c/89270 - honor registered_builtin_types in type_for_size
@ 2023-12-05  7:35 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-12-05  7:35 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4dd02d62abd76a69f65d9f3fed6febeed53fc90a

commit r14-6134-g4dd02d62abd76a69f65d9f3fed6febeed53fc90a
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Dec 4 14:03:37 2023 +0100

    c/89270 - honor registered_builtin_types in type_for_size
    
    The following fixes the intermediate conversions inserted by
    convert_to_integer when facing address-spaces and converts
    to their effective [u]intptr_t when they are registered_builtin_types
    by considering those also from c_common_type_for_size and not
    only from c_common_type_for_mode.
    
            PR c/89270
    gcc/c-family/
            * c-common.cc (c_common_type_for_size): Consider
            registered_builtin_types.
    
    gcc/testsuite/
            * gcc.target/avr/pr89270.c: New testcase.

Diff:
---
 gcc/c-family/c-common.cc               | 9 +++++++++
 gcc/testsuite/gcc.target/avr/pr89270.c | 7 +++++++
 2 files changed, 16 insertions(+)

diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index b2b70c99338..d175054dddb 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -2362,6 +2362,15 @@ c_common_type_for_size (unsigned int bits, int unsignedp)
     return (unsignedp ? widest_unsigned_literal_type_node
 	    : widest_integer_literal_type_node);
 
+  for (tree t = registered_builtin_types; t; t = TREE_CHAIN (t))
+    {
+      tree type = TREE_VALUE (t);
+      if (TREE_CODE (type) == INTEGER_TYPE
+	  && bits == TYPE_PRECISION (type)
+	  && !!unsignedp == !!TYPE_UNSIGNED (type))
+	return type;
+    }
+
   if (bits <= TYPE_PRECISION (intQI_type_node))
     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
 
diff --git a/gcc/testsuite/gcc.target/avr/pr89270.c b/gcc/testsuite/gcc.target/avr/pr89270.c
new file mode 100644
index 00000000000..2b6e4a8aa5b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/pr89270.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+
+void test()
+{
+  extern const unsigned char __memx __data_load_end;
+  __uint24 top=(__uint24)&__data_load_end;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-05  7:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-05  7:35 [gcc r14-6134] c/89270 - honor registered_builtin_types in type_for_size Richard Biener

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).