c: Restore warning for incomplete structures declared in parameter list [PR117866]
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
Commit Message
Happy new year! Please consider the following patch.
Bootstrapped and regression tested on x86_64.
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/117886
gcc/c/ChangeLog:
* c-decl.cc (get_parm_info): Change condition for warning.
gcc/testsuite/ChangeLog:
* gcc.dg/pr117866.c: New test.
* gcc.dg/struct-pr118007.c: Adapt.
Comments
On Mon, 6 Jan 2025, Martin Uecker wrote:
>
> Happy new year! Please consider the following patch.
>
> Bootstrapped and regression tested on x86_64.
>
>
> 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/117886
>
> gcc/c/ChangeLog:
> * c-decl.cc (get_parm_info): Change condition for warning.
>
> gcc/testsuite/ChangeLog:
> * gcc.dg/pr117866.c: New test.
> * gcc.dg/struct-pr118007.c: Adapt.
OK.
@@ -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"
new file mode 100644
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c23" } */
+
+void convert(struct fractpoint *pt); /* { dg-warning "declared inside parameter list" } */
+
@@ -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" } */