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.
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"
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-std=c23" } */
+
+void convert(struct fractpoint *pt); /* { dg-warning "declared inside parameter list" } */
+
/* { 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" } */