From 2be4dfcbc119f1f3d68dc20800ade2bf4cf5d9ae Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 31 Jan 2018 22:12:46 +0000 Subject: [PATCH] re PR c/81779 (bool define from stdbool.h suppresses -Wdeclaration-after-statement) PR c/81779 * c-parser.c (c_parser_compound_statement_nostart): Call expansion_point_location_if_in_system_header. * gcc.dg/pr81779.c: New test. From-SVN: r257271 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-parser.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr81779.c | 15 +++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr81779.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 52ed9f05e4c..561b58e82da 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2018-01-31 Marek Polacek + + PR c/81779 + * c-parser.c (c_parser_compound_statement_nostart): Call + expansion_point_location_if_in_system_header. + 2018-01-17 David Malcolm PR c++/83814 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 3327dc915e9..5e3512a9127 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -4975,6 +4975,7 @@ c_parser_compound_statement_nostart (c_parser *parser) while (c_parser_next_token_is_not (parser, CPP_CLOSE_BRACE)) { location_t loc = c_parser_peek_token (parser)->location; + loc = expansion_point_location_if_in_system_header (loc); if (c_parser_next_token_is_keyword (parser, RID_CASE) || c_parser_next_token_is_keyword (parser, RID_DEFAULT) || (c_parser_next_token_is (parser, CPP_NAME) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4dd7c6df7aa..149df85427c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-31 Marek Polacek + + PR c/81779 + * gcc.dg/pr81779.c: New test. + 2018-01-31 Jakub Jelinek PR fortran/84116 diff --git a/gcc/testsuite/gcc.dg/pr81779.c b/gcc/testsuite/gcc.dg/pr81779.c new file mode 100644 index 00000000000..6e796384a67 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr81779.c @@ -0,0 +1,15 @@ +/* PR c/81779 */ +/* { dg-do compile } */ +/* { dg-options "-Wdeclaration-after-statement" } */ + +#include + +bool +f2 (char *p) +{ + if (!p) + return false; + + bool ret = true; /* { dg-warning "ISO C90 forbids mixed declarations and code" } */ + return ret; +} -- 2.30.2