https://gcc.gnu.org/g:21571cdd8355f2162910d40f2f72222d2dd4046f
commit r15-6747-g21571cdd8355f2162910d40f2f72222d2dd4046f Author: Martin Uecker <uec...@tugraz.at> Date: Mon Jan 6 15:32:16 2025 +0100 c: Restore warning for incomplete structures declared in parameter list [PR117866] In C23 mode the warning about declaring structures and union in parameter lists was removed, because it is possible to redeclare a compatible type elsewhere. This is not the case for incomplete types, so restore the warning for those types. PR c/117866 gcc/c/ChangeLog: * c-decl.cc (get_parm_info): Change condition for warning. gcc/testsuite/ChangeLog: * gcc.dg/pr117866.c: New test. * gcc.dg/strub-pr118007.c: Adapt. Diff: --- gcc/c/c-decl.cc | 2 +- gcc/testsuite/gcc.dg/pr117866.c | 5 +++++ gcc/testsuite/gcc.dg/strub-pr118007.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index f60b2a54a17a..56d13884182d 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -8677,7 +8677,7 @@ get_parm_info (bool ellipsis, tree expr) if (b->id) { /* The %s will be one of 'struct', 'union', or 'enum'. */ - if (!flag_isoc23) + if (!flag_isoc23 || !COMPLETE_TYPE_P (decl)) warning_at (b->locus, 0, "%<%s %E%> declared inside parameter list" " will not be visible outside of this definition or" diff --git a/gcc/testsuite/gcc.dg/pr117866.c b/gcc/testsuite/gcc.dg/pr117866.c new file mode 100644 index 000000000000..3caf707791d3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr117866.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c23" } */ + +void convert(struct fractpoint *pt); /* { dg-warning "declared inside parameter list" } */ + diff --git a/gcc/testsuite/gcc.dg/strub-pr118007.c b/gcc/testsuite/gcc.dg/strub-pr118007.c index 6c24cad65296..51f48245b3f2 100644 --- a/gcc/testsuite/gcc.dg/strub-pr118007.c +++ b/gcc/testsuite/gcc.dg/strub-pr118007.c @@ -2,4 +2,4 @@ /* { dg-do compile } */ /* { dg-options "-fstrub=all -O2" } */ -void rb_ec_error_print(struct rb_execution_context_struct *volatile) {} +void rb_ec_error_print(struct rb_execution_context_struct *volatile) {} /* { dg-warning "declared inside parameter list" } */