From 6b16805ede8c2ea6163d01a61c1a087497d2a769 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 21 Nov 2000 07:55:42 +0100 Subject: [PATCH] expr.c (do_compare_and_jump): If op0 was replaced by promoted integer constant, use type of op1 for comparison. * expr.c (do_compare_and_jump): If op0 was replaced by promoted integer constant, use type of op1 for comparison. * g++.old-deja/g++.other/inline17.C: New test. From-SVN: r37605 --- gcc/ChangeLog | 5 +++++ gcc/expr.c | 13 +++++++++++ gcc/testsuite/ChangeLog | 4 ++++ .../g++.old-deja/g++.other/inline17.C | 22 +++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/inline17.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 29361b32903..52963ce7ca3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2000-11-21 Jakub Jelinek + + * expr.c (do_compare_and_jump): If op0 was replaced by promoted + integer constant, use type of op1 for comparison. + 2000-11-20 Stan Shebs * config/rs6000/xm-darwin.h: New file, Darwin host definitions. diff --git a/gcc/expr.c b/gcc/expr.c index 35ccf0359a9..e9cd6eb9002 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -10054,8 +10054,21 @@ do_compare_and_jump (exp, signed_code, unsigned_code, if_false_label, return; op1 = expand_expr_unaligned (TREE_OPERAND (exp, 1), &align1); + if (TREE_CODE (TREE_OPERAND (exp, 1)) == ERROR_MARK) + return; + type = TREE_TYPE (TREE_OPERAND (exp, 0)); mode = TYPE_MODE (type); + if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST + && (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST + || (GET_MODE_BITSIZE (mode) + > GET_MODE_BITSIZE (TREE_TYPE (TREE_OPERAND (exp, 1)))))) + { + /* op0 might have been replaced by promoted constant, in which + case the type of second argument should be used. */ + type = TREE_TYPE (TREE_OPERAND (exp, 1)); + mode = TYPE_MODE (type); + } unsignedp = TREE_UNSIGNED (type); code = unsignedp ? unsigned_code : signed_code; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7d61d578f58..9e94bf63484 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2000-11-21 Jakub Jelinek + + * g++.old-deja/g++.other/inline17.C: New test. + 2000-11-20 Donald Lindsay * gcc.dg/20000614-2.c: Bug fix. This test expected an unitialized diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline17.C b/gcc/testsuite/g++.old-deja/g++.other/inline17.C new file mode 100644 index 00000000000..f3266ab479d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline17.C @@ -0,0 +1,22 @@ +// Build don't link: +// Origin: Jakub Jelinek +// Special g++ Options: -O3 + +struct foo +{ + char a; + foo (); + void bar (); + void baz (char c); +}; + +void foo::baz (char c) +{ + if (c != a) + a = c; +} + +void foo::bar () +{ + baz (1); +}