diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2011-01-27 02:09:13 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2011-01-27 02:09:13 +0000 |
commit | 04af87889f708b66bf19c4ba9f65b7b1e8f18e34 (patch) | |
tree | 3a9c962ac63adb51b3f0d443e86f451d6eee1cc8 /gcc | |
parent | 45d581f7907ebfd5b22456edd52cc7697e65003b (diff) | |
download | gcc-04af87889f708b66bf19c4ba9f65b7b1e8f18e34.zip gcc-04af87889f708b66bf19c4ba9f65b7b1e8f18e34.tar.gz gcc-04af87889f708b66bf19c4ba9f65b7b1e8f18e34.tar.bz2 |
In gcc/: 2011-01-26 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/:
2011-01-26 Nicola Pero <nicola.pero@meta-innovation.com>
PR c/43082
* c-typeck.c (c_objc_common_truthvalue_conversion): If we are
passed a VOID_TYPE expression, immediately emit an error and
return error_mark_node.
In gcc/testsuite/:
2011-01-26 Nicola Pero <nicola.pero@meta-innovation.com>
Andrew Pinski <pinskia@gmail.com>
PR c/43082
* gcc.dg/pr43082.c: New.
Co-Authored-By: Andrew Pinski <pinskia@gmail.com>
From-SVN: r169319
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-typeck.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr43082.c | 10 |
4 files changed, 29 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 35e555b..c0389d4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-01-26 Nicola Pero <nicola.pero@meta-innovation.com> + + PR c/43082 + * c-typeck.c (c_objc_common_truthvalue_conversion): If we are + passed a VOID_TYPE expression, immediately emit an error and + return error_mark_node. + 2011-01-26 Jeff Law <law@redhat.com> PR rtl-optimization/47464 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 689423e..a22bb73 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -10270,6 +10270,10 @@ c_objc_common_truthvalue_conversion (location_t location, tree expr) error_at (location, "used union type value where scalar is required"); return error_mark_node; + case VOID_TYPE: + error_at (location, "void value not ignored as it ought to be"); + return error_mark_node; + case FUNCTION_TYPE: gcc_unreachable (); @@ -10282,8 +10286,8 @@ c_objc_common_truthvalue_conversion (location_t location, tree expr) if (int_operands) expr = remove_c_maybe_const_expr (expr); - /* ??? Should we also give an error for void and vectors rather than - leaving those to give errors later? */ + /* ??? Should we also give an error for vectors rather than leaving + those to give errors later? */ expr = c_common_truthvalue_conversion (location, expr); if (TREE_CODE (expr) == INTEGER_CST && int_operands && !int_const) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a4ed365..6835c19 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-01-26 Nicola Pero <nicola.pero@meta-innovation.com> + Andrew Pinski <pinskia@gmail.com> + + PR c/43082 + * gcc.dg/pr43082.c: New. + 2011-01-26 DJ Delorie <dj@redhat.com> PR rtl-optimization/46878 diff --git a/gcc/testsuite/gcc.dg/pr43082.c b/gcc/testsuite/gcc.dg/pr43082.c new file mode 100644 index 0000000..a6e0046 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr43082.c @@ -0,0 +1,10 @@ +/* Test that the compiler does not crash when void expressions are + found inside conditional expressions. PR c/43082. */ +/* { dg-do compile } */ + +void +foo (int x) +{ + if (x ? (void)(0) : (void)(1)) /* { dg-error "void value not ignored as it ought to be" } */ + ; +} |