aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-warn.cc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2022-03-29 14:36:55 -0400
committerMarek Polacek <polacek@redhat.com>2022-03-30 10:23:06 -0400
commit5db9ce171019f8915885cebd5cc5f4101bb926e6 (patch)
tree96da600dda585dd7edec8d835db72f59ed4e18f5 /gcc/c-family/c-warn.cc
parent3aaf9bf77047aecc23072fe3db7f13ecff72a7cf (diff)
downloadgcc-5db9ce171019f8915885cebd5cc5f4101bb926e6.zip
gcc-5db9ce171019f8915885cebd5cc5f4101bb926e6.tar.gz
gcc-5db9ce171019f8915885cebd5cc5f4101bb926e6.tar.bz2
c-family: ICE with -Wconversion and A ?: B [PR101030]
This patch fixes a crash in conversion_warning on a null expression. It is null because the testcase uses the GNU A ?: B extension. We could also use op0 instead of op1 in this case, but it doesn't seem to be necessary. PR c++/101030 gcc/c-family/ChangeLog: * c-warn.cc (conversion_warning) <case COND_EXPR>: Don't call conversion_warning when OP1 is null. gcc/testsuite/ChangeLog: * g++.dg/ext/cond5.C: New test.
Diffstat (limited to 'gcc/c-family/c-warn.cc')
-rw-r--r--gcc/c-family/c-warn.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc
index 9025fc1..f24ac5d 100644
--- a/gcc/c-family/c-warn.cc
+++ b/gcc/c-family/c-warn.cc
@@ -1300,7 +1300,7 @@ conversion_warning (location_t loc, tree type, tree expr, tree result)
tree op1 = TREE_OPERAND (expr, 1);
tree op2 = TREE_OPERAND (expr, 2);
- return (conversion_warning (loc, type, op1, result)
+ return ((op1 && conversion_warning (loc, type, op1, result))
|| conversion_warning (loc, type, op2, result));
}