diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2012-11-07 16:58:03 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2012-11-07 16:58:03 +0000 |
commit | a8fa98e35a77e7d13395b363953cde99c62f7e2b (patch) | |
tree | 0971d353c36c1931f05e569bcfda7a563741f4f0 /gcc/c-family | |
parent | f52c312a1b67f6324be389c2d3569a668d36eaae (diff) |
2012-11-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/51294
c-family/
* c-common.c (conversion_warning): Handle conditional expressions.
testsuite/
* c-c++-common/pr51294.c: New.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@193301 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 24 |
2 files changed, 13 insertions, 16 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index f7c942216bc..6f343ef2419 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2012-11-07 Manuel López-Ibáñez <manu@gcc.gnu.org> + + PR c/51294 + * c-common.c (conversion_warning): Handle conditional expressions. + 2012-10-29 Jonathan Wakely <jwakely.gcc@gmail.com> PR c++/54930 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 840bc84c6d2..90c1992129f 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -2670,22 +2670,14 @@ conversion_warning (tree type, tree expr) case COND_EXPR: { - /* In case of COND_EXPR, if both operands are constants or - COND_EXPR, then we do not care about the type of COND_EXPR, - only about the conversion of each operand. */ - tree op1 = TREE_OPERAND (expr, 1); - tree op2 = TREE_OPERAND (expr, 2); - - if ((TREE_CODE (op1) == REAL_CST || TREE_CODE (op1) == INTEGER_CST - || TREE_CODE (op1) == COND_EXPR) - && (TREE_CODE (op2) == REAL_CST || TREE_CODE (op2) == INTEGER_CST - || TREE_CODE (op2) == COND_EXPR)) - { - conversion_warning (type, op1); - conversion_warning (type, op2); - return; - } - /* Fall through. */ + /* In case of COND_EXPR, we do not care about the type of + COND_EXPR, only about the conversion of each operand. */ + tree op1 = TREE_OPERAND (expr, 1); + tree op2 = TREE_OPERAND (expr, 2); + + conversion_warning (type, op1); + conversion_warning (type, op2); + return; } default: /* 'expr' is not a constant. */ |