aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-05-01 04:09:06 +0000
committerRichard Stallman <rms@gnu.org>1993-05-01 04:09:06 +0000
commit257e61ed70f52c514f9486ee4d37a501245a069b (patch)
tree257410d7731912b96b1b811c9043fc4aafa93b55 /gcc
parent5f0abdc3ca190343317ef72988e0d49743a34c60 (diff)
downloadgcc-257e61ed70f52c514f9486ee4d37a501245a069b.zip
gcc-257e61ed70f52c514f9486ee4d37a501245a069b.tar.gz
gcc-257e61ed70f52c514f9486ee4d37a501245a069b.tar.bz2
(truthvalue_conversion): Specific error message when the "truthvalue" of a struct...
(truthvalue_conversion): Specific error message when the "truthvalue" of a struct, union, or array type operand is needed. From-SVN: r4293
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-common.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index e4d161f..f4a966e 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -955,6 +955,29 @@ truthvalue_conversion (expr)
{
register enum tree_code code;
+ if (TREE_CODE (expr) == ERROR_MARK)
+ return expr;
+
+ /* These really should return error_mark_node after 2.4 is stable.
+ But not all callers handle ERROR_MARK properly. */
+ switch (TREE_CODE (TREE_TYPE (expr)))
+ {
+ case RECORD_TYPE:
+ error ("struct type value used where scalar is required");
+ return integer_zero_node;
+
+ case UNION_TYPE:
+ error ("union type value used where scalar is required");
+ return integer_zero_node;
+
+ case ARRAY_TYPE:
+ error ("array type value used where scalar is required");
+ return integer_zero_node;
+
+ default:
+ break;
+ }
+
switch (TREE_CODE (expr))
{
/* It is simpler and generates better code to have only TRUTH_*_EXPR