* [committed] Fix thinko in -Wmultistatement-macros (PR bootstrap/81216)
@ 2017-06-27 7:25 Marek Polacek
0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2017-06-27 7:25 UTC (permalink / raw)
To: GCC Patches
A missing initialization broke bootstrap pretty much everywhere except
x86_64-linux, which is what the -Wmultistatement-macros patch was tested
on.
Sorry for the breakage :(.
Bootstrapped/regtested on x86_64-linux/ppc64-linux, applying to trunk.
2017-06-27 Marek Polacek <polacek@redhat.com>
PR bootstrap/81216
* parser.c (cp_parser_already_scoped_statement): Initialize
LOC_AFTER_LABELS.
* g++.dg/warn/Wmultistatement-macros-1.C: New test.
diff --git gcc/cp/parser.c gcc/cp/parser.c
index c405fe5..573b97a 100644
--- gcc/cp/parser.c
+++ gcc/cp/parser.c
@@ -12438,7 +12438,7 @@ cp_parser_already_scoped_statement (cp_parser* parser, bool *if_p,
{
token_indent_info body_tinfo
= get_token_indent_info (cp_lexer_peek_token (parser->lexer));
- location_t loc_after_labels;
+ location_t loc_after_labels = UNKNOWN_LOCATION;
cp_parser_statement (parser, NULL_TREE, false, if_p, NULL,
&loc_after_labels);
@@ -12446,7 +12446,8 @@ cp_parser_already_scoped_statement (cp_parser* parser, bool *if_p,
= get_token_indent_info (cp_lexer_peek_token (parser->lexer));
warn_for_misleading_indentation (guard_tinfo, body_tinfo, next_tinfo);
- if (next_tinfo.type != CPP_SEMICOLON)
+ if (loc_after_labels != UNKNOWN_LOCATION
+ && next_tinfo.type != CPP_SEMICOLON)
warn_for_multistatement_macros (loc_after_labels, next_tinfo.location,
guard_tinfo.location,
guard_tinfo.keyword);
diff --git gcc/testsuite/g++.dg/warn/Wmultistatement-macros-1.C gcc/testsuite/g++.dg/warn/Wmultistatement-macros-1.C
index e69de29..b27958d 100644
--- gcc/testsuite/g++.dg/warn/Wmultistatement-macros-1.C
+++ gcc/testsuite/g++.dg/warn/Wmultistatement-macros-1.C
@@ -0,0 +1,13 @@
+// PR bootstrap/81216
+// { dg-options "-Wmultistatement-macros" }
+// { dg-do compile }
+
+template <typename A, typename B>
+static bool
+equal (A a, A b, B c)
+{
+ for (; a != b; ++a, (void)++c)
+ if (!(*a == *c))
+ return false;
+ return true;
+}
Marek
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-06-27 7:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27 7:25 [committed] Fix thinko in -Wmultistatement-macros (PR bootstrap/81216) Marek Polacek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).