Bug 85318 - -Wc90-c99-compat does not warn about for loop initial declarations
Summary: -Wc90-c99-compat does not warn about for loop initial declarations
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 7.3.1
: P3 normal
Target Milestone: ---
Assignee: Marek Polacek
URL:
Keywords: diagnostic, easyhack
Depends on:
Blocks:
 
Reported: 2018-04-10 09:57 UTC by Thorsten Otto
Modified: 2018-06-07 19:17 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-04-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thorsten Otto 2018-04-10 09:57:24 UTC
When compiling code that uses for loop initial declarations with -Wc90-c99-compat, no diagnostic is issued.
Comment 1 Andrew Pinski 2018-04-11 02:02:58 UTC
Confirmed.

This should not be hard to add.
The error message while compiling for C90 is emitted from check_for_loop_decls which should be easy to add a warning there when -Wc90-c99-compat is turned on.
Comment 2 Marek Polacek 2018-06-07 19:16:17 UTC
Author: mpolacek
Date: Thu Jun  7 19:15:45 2018
New Revision: 261293

URL: https://gcc.gnu.org/viewcvs?rev=261293&root=gcc&view=rev
Log:
	PR c/85318
	* c-decl.c (check_for_loop_decls): Add -Wc90-c99-compat warning about
	for loop initial declarations.

	* gcc.dg/Wc90-c99-compat-10.c: New test.
	* gcc.dg/Wc90-c99-compat-11.c: New test.
	* gcc.dg/Wc90-c99-compat-12.c: New test.
	* gcc.dg/Wc90-c99-compat-9.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/Wc90-c99-compat-10.c
    trunk/gcc/testsuite/gcc.dg/Wc90-c99-compat-11.c
    trunk/gcc/testsuite/gcc.dg/Wc90-c99-compat-12.c
    trunk/gcc/testsuite/gcc.dg/Wc90-c99-compat-9.c
Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Marek Polacek 2018-06-07 19:17:00 UTC
Fixed for GCC 9.