From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Cc: "Joseph S. Myers" <joseph@codesourcery.com>
Subject: [PATCH] c/89270 - honor registered_builtin_types in type_for_size
Date: Mon, 4 Dec 2023 14:24:29 +0100 (CET) [thread overview]
Message-ID: <20231204132429.AB3CA13588@imap2.dmz-prg2.suse.org> (raw)
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.
Bootstrap and regtest on x86_64-unknown-linux-gnu, OK?
Thanks,
Richard.
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.
---
gcc/c-family/c-common.cc | 9 +++++++++
gcc/testsuite/gcc.target/avr/pr89270.c | 7 +++++++
2 files changed, 16 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/avr/pr89270.c
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;
+}
--
2.35.3
next reply other threads:[~2023-12-04 13:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 13:24 Richard Biener [this message]
2023-12-04 21:24 ` Joseph Myers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231204132429.AB3CA13588@imap2.dmz-prg2.suse.org \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=joseph@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).