diff options
author | mueller <mueller@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-14 19:33:17 +0000 |
---|---|---|
committer | mueller <mueller@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-14 19:33:17 +0000 |
commit | ffe8fd56ff81e2ec9913458c3787d534970dc685 (patch) | |
tree | 6eaa29a86e707ec20730717f602d38ed322cf784 /gcc/testsuite | |
parent | 0a6b5f6b02d7417cf1267d62c8cd6a6a9cc0774f (diff) | |
download | gcc-ffe8fd56ff81e2ec9913458c3787d534970dc685.tar.gz |
2007-03-14 Dirk Mueller <dmueller@suse.de>
* c-common.h (empty_body_warning): Rename to empty_if_body_warning.
* c-common.c (empty_if_body_warning): Rephrase diagnostic message.
* c-parser.c (c_parser_if_body): Always add an empty statement in case
of empty body.
* c-parser.c (c_parser_do_statement): Warn about empty body in
do/while statement.
* c-typeck (c_finish_if_stmt): Call empty_if_body_warning.
* doc/invoke.texi (-Wempty-body): Update documentation.
* cp/semantics.c (c_finish_if_stmt): Call empty_if_body_warning.
(finish_do_body): Warn about empty body in do/while statement.
* g++.dg/warn/do-empty.C: New.
* gcc.dg/do-empty.c: New.
* gcc.dg/if-empty-1.c: Update.
* gcc.dg/20001116-1.c: Update.
* gcc.dg/pr23165.c: Update.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122928 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/do-empty.C | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/20001116-1.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/do-empty.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/if-empty-1.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr23165.c | 2 |
6 files changed, 42 insertions, 4 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d3713ed19ec..e0d27c55562 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2007-03-14 Dirk Mueller <dmueller@suse.de> + + * g++.dg/warn/do-empty.C: New. + * gcc.dg/do-empty.c: New. + * gcc.dg/if-empty-1.c: Update. + * gcc.dg/20001116-1.c: Update. + * gcc.dg/pr23165.c: Update. + 2007-03-14 Jakub Jelinek <jakub@redhat.com> * gfortran.dg/module_implicit_conversion.f90: New test. diff --git a/gcc/testsuite/g++.dg/warn/do-empty.C b/gcc/testsuite/g++.dg/warn/do-empty.C new file mode 100644 index 00000000000..350261d48ed --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/do-empty.C @@ -0,0 +1,15 @@ +/* Test diagnostics for empty bodies in do / while. */ +/* { dg-do compile } */ +/* { dg-options "-Wempty-body" } */ + +void +f (int x) +{ + do + ; /* { dg-warning "empty body in" } */ + while (x--); + + do + {} /* { dg-bogus "empty body in" } */ + while (++x < 10); +} diff --git a/gcc/testsuite/gcc.dg/20001116-1.c b/gcc/testsuite/gcc.dg/20001116-1.c index 3ea2f381d07..8b1e919c66f 100644 --- a/gcc/testsuite/gcc.dg/20001116-1.c +++ b/gcc/testsuite/gcc.dg/20001116-1.c @@ -7,5 +7,5 @@ void foo (int x) { if (x) - ; /* { dg-warning "empty body in an if-statement" } */ + ; /* { dg-warning "empty body in an" } */ } diff --git a/gcc/testsuite/gcc.dg/do-empty.c b/gcc/testsuite/gcc.dg/do-empty.c new file mode 100644 index 00000000000..350261d48ed --- /dev/null +++ b/gcc/testsuite/gcc.dg/do-empty.c @@ -0,0 +1,15 @@ +/* Test diagnostics for empty bodies in do / while. */ +/* { dg-do compile } */ +/* { dg-options "-Wempty-body" } */ + +void +f (int x) +{ + do + ; /* { dg-warning "empty body in" } */ + while (x--); + + do + {} /* { dg-bogus "empty body in" } */ + while (++x < 10); +} diff --git a/gcc/testsuite/gcc.dg/if-empty-1.c b/gcc/testsuite/gcc.dg/if-empty-1.c index 9785c72a181..a129832c337 100644 --- a/gcc/testsuite/gcc.dg/if-empty-1.c +++ b/gcc/testsuite/gcc.dg/if-empty-1.c @@ -7,7 +7,7 @@ void f (int x) { if (x) - ; /* { dg-warning "warning: empty body in an if-statement" } */ + ; /* { dg-warning "warning: empty body in an" } */ if (x) ; /* By design we don't warn in this case. */ else @@ -15,7 +15,7 @@ f (int x) if (x) (void)0; else - ; /* { dg-warning "warning: empty body in an else-statement" } */ + ; /* { dg-warning "warning: empty body in an" } */ if (x) (void)0; else diff --git a/gcc/testsuite/gcc.dg/pr23165.c b/gcc/testsuite/gcc.dg/pr23165.c index 94e7daebc90..49194a1462d 100644 --- a/gcc/testsuite/gcc.dg/pr23165.c +++ b/gcc/testsuite/gcc.dg/pr23165.c @@ -3,7 +3,7 @@ void foo (void) { if (0) - a: ; /* { dg-warning "empty body in an if-statement" } */ + a: ; /* { dg-warning "empty body in an" } */ } |