diff options
author | Marek Polacek <polacek@redhat.com> | 2016-04-13 16:28:46 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2016-04-13 16:28:46 +0000 |
commit | b3a77f2137ef26d4d74cc40af7a42be7901ac98d (patch) | |
tree | af4aa61b9b882456a43642bc3e92952010b2e8ac | |
parent | 99cd9857c01234bb5b6cbff54e1bd2a400c04179 (diff) | |
download | gcc-b3a77f2137ef26d4d74cc40af7a42be7901ac98d.zip gcc-b3a77f2137ef26d4d74cc40af7a42be7901ac98d.tar.gz gcc-b3a77f2137ef26d4d74cc40af7a42be7901ac98d.tar.bz2 |
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
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-indentation.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c | 11 |
4 files changed, 27 insertions, 4 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 26b1dab..f842efc 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -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> * c-cppbuiltin.c (c_cpp_builtins): Update __cpp_range_based_for. diff --git a/gcc/c-family/c-indentation.c b/gcc/c-family/c-indentation.c index 1da3f68..8c33686 100644 --- a/gcc/c-family/c-indentation.c +++ b/gcc/c-family/c-indentation.c @@ -239,10 +239,11 @@ should_warn_for_misleading_indentation (const token_indent_info &guard_tinfo, if (line_table->seen_line_directive) return false; - /* We can't usefully warn about do-while statements since the bodies of these - statements are always explicitly delimited at both ends, so control flow is - quite obvious. */ - if (guard_tinfo.keyword == RID_DO) + /* We can't usefully warn about do-while and switch statements since the + bodies of these statements are always explicitly delimited at both ends, + so control flow is quite obvious. */ + if (guard_tinfo.keyword == RID_DO + || guard_tinfo.keyword == RID_SWITCH) return false; /* If the token following the body is a close brace or an "else" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6edb320..c806113 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 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> + PR c/70436 * testsuite/gcc.dg/Wparentheses-12.c: New test. * testsuite/gcc.dg/Wparentheses-13.c: New test. diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c b/gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c new file mode 100644 index 0000000..d15a479 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c @@ -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); +} |