From e9527cfd9665e3cb0887682ccb0d17d040732799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez?= Date: Wed, 27 Aug 2008 23:54:36 +0000 Subject: re PR c/31673 ("`for' loop initial declaration used outside C99 mode" is confusing) 2008-08-27 Manuel Lopez-Ibanez PR c/31673 * c-decl.c (check_for_loop_decls): Improve error message. Give hint. testsuite/ * gcc.dg/c90-fordecl-1.c: Update. From-SVN: r139681 --- gcc/c-decl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gcc/c-decl.c') diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 056cb38..ee04d9a 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -6796,13 +6796,19 @@ check_for_loop_decls (void) tree one_decl = NULL_TREE; int n_decls = 0; - if (!flag_isoc99) { + static bool hint = true; /* If we get here, declarations have been used in a for loop without the C99 for loop scope. This doesn't make much sense, so don't allow it. */ - error ("% loop initial declaration used outside C99 mode"); + error ("% loop initial declarations are only allowed in C99 mode"); + if (hint) + { + inform (input_location, + "use option -std=c99 or -std=gnu99 to compile your code"); + hint = false; + } return NULL_TREE; } /* C99 subclause 6.8.5 paragraph 3: -- cgit v1.1