re PR c++/70639 (internal compiler error: in guard_tinfo_to_string, at c-family/c-indentation.c:560)

PR c++/70639
	* c-indentation.c (should_warn_for_misleading_indentation): Bail out
	for switch statements, too.

	* c-c++-common/Wmisleading-indentation-4.c: New test.

From-SVN: r234952
This commit is contained in:
Marek Polacek 2016-04-13 16:28:46 +00:00 committed by Marek Polacek
parent 99cd9857c0
commit b3a77f2137
4 changed files with 27 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2016-04-13 Marek Polacek <polacek@redhat.com>
PR c++/70639
* c-indentation.c (should_warn_for_misleading_indentation): Bail out
for switch statements, too.
2016-03-28 Jason Merrill <jason@redhat.com> 2016-03-28 Jason Merrill <jason@redhat.com>
* c-cppbuiltin.c (c_cpp_builtins): Update __cpp_range_based_for. * c-cppbuiltin.c (c_cpp_builtins): Update __cpp_range_based_for.

View File

@ -239,10 +239,11 @@ should_warn_for_misleading_indentation (const token_indent_info &guard_tinfo,
if (line_table->seen_line_directive) if (line_table->seen_line_directive)
return false; return false;
/* We can't usefully warn about do-while statements since the bodies of these /* We can't usefully warn about do-while and switch statements since the
statements are always explicitly delimited at both ends, so control flow is bodies of these statements are always explicitly delimited at both ends,
quite obvious. */ so control flow is quite obvious. */
if (guard_tinfo.keyword == RID_DO) if (guard_tinfo.keyword == RID_DO
|| guard_tinfo.keyword == RID_SWITCH)
return false; return false;
/* If the token following the body is a close brace or an "else" /* If the token following the body is a close brace or an "else"

View File

@ -1,3 +1,8 @@
2016-04-13 Marek Polacek <polacek@redhat.com>
PR c++/70639
* c-c++-common/Wmisleading-indentation-4.c: New test.
2016-04-13 Marek Polacek <polacek@redhat.com> 2016-04-13 Marek Polacek <polacek@redhat.com>
PR c/70436 PR c/70436

View File

@ -0,0 +1,11 @@
/* PR c++/70639 */
/* { dg-do compile } */
/* { dg-options "-Wmisleading-indentation" } */
void bar (int);
void
foo (int x)
{
switch (x);
bar (x);
}