[gcc r12-11223] lto/113207 - fix free_lang_data_in_type
Richard Biener
rguenth@gcc.gnu.org
Tue Jun 24 11:10:51 GMT 2025
https://gcc.gnu.org/g:07490d983161912fa314607c5a5beb9c49cc4a3f
commit r12-11223-g07490d983161912fa314607c5a5beb9c49cc4a3f
Author: Richard Biener <rguenther@suse.de>
Date: Mon Feb 3 14:27:01 2025 +0100
lto/113207 - fix free_lang_data_in_type
When we process function types we strip volatile and const qualifiers
after building a simplified type variant (which preserves those).
The qualified type handling of both isn't really compatible, so avoid
bad interaction by swapping this, first dropping const/volatile
qualifiers and then building the simplified type thereof.
PR lto/113207
* ipa-free-lang-data.cc (free_lang_data_in_type): First drop
const/volatile qualifiers from function argument types,
then build a simplified type.
* gcc.dg/pr113207.c: New testcase.
(cherry picked from commit a55e14b239181381204c615335929b3316d75370)
Diff:
---
gcc/ipa-free-lang-data.cc | 3 +--
gcc/testsuite/gcc.dg/pr113207.c | 10 ++++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/gcc/ipa-free-lang-data.cc b/gcc/ipa-free-lang-data.cc
index a742156858cd..6fef047e3beb 100644
--- a/gcc/ipa-free-lang-data.cc
+++ b/gcc/ipa-free-lang-data.cc
@@ -436,9 +436,7 @@ free_lang_data_in_type (tree type, class free_lang_data_d *fld)
different front ends. */
for (tree p = TYPE_ARG_TYPES (type); p; p = TREE_CHAIN (p))
{
- TREE_VALUE (p) = fld_simplified_type (TREE_VALUE (p), fld);
tree arg_type = TREE_VALUE (p);
-
if (TYPE_READONLY (arg_type) || TYPE_VOLATILE (arg_type))
{
int quals = TYPE_QUALS (arg_type)
@@ -448,6 +446,7 @@ free_lang_data_in_type (tree type, class free_lang_data_d *fld)
if (!fld->pset.add (TREE_VALUE (p)))
free_lang_data_in_type (TREE_VALUE (p), fld);
}
+ TREE_VALUE (p) = fld_simplified_type (TREE_VALUE (p), fld);
/* C++ FE uses TREE_PURPOSE to store initial values. */
TREE_PURPOSE (p) = NULL;
}
diff --git a/gcc/testsuite/gcc.dg/pr113207.c b/gcc/testsuite/gcc.dg/pr113207.c
new file mode 100644
index 000000000000..81f53d8fcc2f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr113207.c
@@ -0,0 +1,10 @@
+/* { dg-compile } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-flto -fchecking" } */
+
+typedef struct cl_lispunion *cl_object;
+struct cl_lispunion {};
+cl_object cl_error() __attribute__((noreturn));
+volatile cl_object cl_coerce_value0;
+void cl_coerce() { cl_error(); }
+void L66safe_canonical_type(cl_object volatile);
More information about the Gcc-cvs
mailing list