aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2025-05-01 11:40:17 -0400
committerJason Merrill <jason@redhat.com>2025-05-02 07:47:17 -0400
commit4af5de21363cfdd2be227c05dfdee7e053337f6a (patch)
tree645589edac54029a7def702dbdbdc29e69b72ce4
parent0e65fef8717f404cf9c85bff51bf87d534f87828 (diff)
downloadgcc-4af5de21363cfdd2be227c05dfdee7e053337f6a.zip
gcc-4af5de21363cfdd2be227c05dfdee7e053337f6a.tar.gz
gcc-4af5de21363cfdd2be227c05dfdee7e053337f6a.tar.bz2
i386: -Wabi false positive with indirect call [PR60336]
This warning relies on the TRANSLATION_UNIT_WARN_EMPTY_P flag (set in cxx_init_decl_processing) to decide whether we want to warn about the GCC 8 empty class parameter passing fix, but in a call through a function pointer we don't have a translation unit and so complain for any -Wabi flag, even now long after this was likely to be relevant. In that situation, let's check the TU for current_function_decl instead. And if we still can't come up with a TU, default to not warning. PR c++/60336 gcc/ChangeLog: * config/i386/i386.cc (ix86_warn_parameter_passing_abi): If no target, check the current TU. gcc/testsuite/ChangeLog: * g++.dg/abi/pr60336-8a.C: New test.
-rw-r--r--gcc/config/i386/i386.cc11
-rw-r--r--gcc/testsuite/g++.dg/abi/pr60336-8a.C15
2 files changed, 23 insertions, 3 deletions
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 2f84033..cb348cb 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -18084,9 +18084,14 @@ ix86_warn_parameter_passing_abi (cumulative_args_t cum_v, tree type)
if (cum->decl && !TREE_PUBLIC (cum->decl))
return;
- const_tree ctx = get_ultimate_context (cum->decl);
- if (ctx != NULL_TREE
- && !TRANSLATION_UNIT_WARN_EMPTY_P (ctx))
+ tree decl = cum->decl;
+ if (!decl)
+ /* If we don't know the target, look at the current TU. */
+ decl = current_function_decl;
+
+ const_tree ctx = get_ultimate_context (decl);
+ if (ctx == NULL_TREE
+ || !TRANSLATION_UNIT_WARN_EMPTY_P (ctx))
return;
/* If the actual size of the type is zero, then there is no change
diff --git a/gcc/testsuite/g++.dg/abi/pr60336-8a.C b/gcc/testsuite/g++.dg/abi/pr60336-8a.C
new file mode 100644
index 0000000..a051843
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/pr60336-8a.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options "-O2 -Wabi=12" }
+
+struct dummy { struct{} a[7][3]; };
+
+extern void test1 (struct dummy, ...);
+extern void (*test2) (struct dummy, ...);
+
+void
+foo ()
+{
+ struct dummy a0;
+ test1 (a0, 42);
+ test2 (a0, 42);
+}