From 54c93c301960dfbc469ee3501ba4872adbfdaf1f Mon Sep 17 00:00:00 2001 From: Ansgar Esztermann Date: Sat, 7 Sep 2002 20:20:35 -0700 Subject: [PATCH] c-typeck.c (c_tree_expr_nonnegative_p): New function. * c-typeck.c (c_tree_expr_nonnegative_p): New function. (build_binary_op): Call c_tree_expr_nonnegative_p rather than tree_expr_nonnegative_p. (build_conditional_expr): Likewise. * c-tree.h (c_tree_expr_nonnegative_p): Declare. * gcc.dg/compare2.c: Remove xfail from cases 10 and 12. From-SVN: r56927 --- gcc/ChangeLog | 34 ++++++++++++++++++++------------- gcc/c-tree.h | 1 + gcc/c-typeck.c | 27 +++++++++++++++++++++++--- gcc/testsuite/ChangeLog | 10 +++++++--- gcc/testsuite/gcc.dg/compare2.c | 4 ++-- 5 files changed, 55 insertions(+), 21 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 731855fd511..6fc185ae984 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2002-09-07 Ansgar Esztermann + + * c-typeck.c (c_tree_expr_nonnegative_p): New function. + (build_binary_op): Call c_tree_expr_nonnegative_p rather than + tree_expr_nonnegative_p. + (build_conditional_expr): Likewise. + * c-tree.h (c_tree_expr_nonnegative_p): Declare. + 2002-09-07 Richard Henderson * builtins.def (inf, inff, infl): Mark const. @@ -53,7 +61,7 @@ Fri Sep 6 13:10:08 2002 Jeffrey A Law (law@redhat.com) - * pentium.md (pentium-firstvboth): Fix typo. + * pentium.md (pentium-firstvboth): Fix typo. 2002-09-06 Dhananjay Deshpande @@ -525,7 +533,7 @@ Tue Sep 3 11:32:14 2002 Nicola Pero PR objc/5956: * objc/objc-act.c (build_typed_selector_reference): Fix typo which was causing the new selector never to match the existing ones - (Patch by Alexander Malmberg ). + (Patch by Alexander Malmberg ). 2002-09-03 Graham Stott @@ -834,17 +842,17 @@ Tue Aug 27 23:03:52 2002 Nicola Pero already been defined, and emit a warning if not. 2002-08-27 Nick Clifton - Catherine Moore - Jim Wilson - - * config.gcc: Add v850e-*-* target. - Add --with-cpu= support for v850. - * config/v850/lib1funcs.asm: Add v850e callt functions. - * config/v850/v850.h: Add support for v850e target. - * config/v850/v850.c: Add functions to support v850e target. - * config/v850/v850-protos.h: Add prototypes for new functions in v850.c. - * config/v850/v850.md: Add patterns for v850e instructions. - * doc/invoke.texi: Document new v850e command line switches. + Catherine Moore + Jim Wilson + + * config.gcc: Add v850e-*-* target. + Add --with-cpu= support for v850. + * config/v850/lib1funcs.asm: Add v850e callt functions. + * config/v850/v850.h: Add support for v850e target. + * config/v850/v850.c: Add functions to support v850e target. + * config/v850/v850-protos.h: Add prototypes for new functions in v850.c. + * config/v850/v850.md: Add patterns for v850e instructions. + * doc/invoke.texi: Document new v850e command line switches. Tue Aug 27 18:30:47 2002 J"orn Rennecke Aldy Hernandez diff --git a/gcc/c-tree.h b/gcc/c-tree.h index aa2fda5d5ea..531cc284559 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -268,6 +268,7 @@ extern tree build_array_ref PARAMS ((tree, tree)); extern tree build_external_ref PARAMS ((tree, int)); extern tree parser_build_binary_op PARAMS ((enum tree_code, tree, tree)); +extern int c_tree_expr_nonnegative_p PARAMS ((tree)); extern void readonly_warning PARAMS ((tree, const char *)); extern tree build_conditional_expr PARAMS ((tree, tree, tree)); extern tree build_compound_expr PARAMS ((tree)); diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index ac77bc234c7..4c6c8bacdf8 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2463,7 +2463,7 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) constant expression involving such literals or a conditional expression involving such literals) and it is non-negative. */ - if (tree_expr_nonnegative_p (sop)) + if (c_tree_expr_nonnegative_p (sop)) /* OK */; /* Do not warn if the comparison is an equality operation, the unsigned quantity is an integral constant, and it @@ -2579,6 +2579,27 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) } } + +/* Return true if `t' is known to be non-negative. */ + +int +c_tree_expr_nonnegative_p (t) + tree t; +{ + if (TREE_CODE (t) == STMT_EXPR) + { + t=COMPOUND_BODY (STMT_EXPR_STMT (t)); + + /* Find the last statement in the chain, ignoring the final + * scope statement */ + while (TREE_CHAIN (t) != NULL_TREE + && TREE_CODE (TREE_CHAIN (t)) != SCOPE_STMT) + t=TREE_CHAIN (t); + return tree_expr_nonnegative_p (TREE_OPERAND (t, 0)); + } + return tree_expr_nonnegative_p (t); +} + /* Return a tree for the difference of pointers OP0 and OP1. The resulting tree has type int. */ @@ -3406,8 +3427,8 @@ build_conditional_expr (ifexp, op1, op2) /* Do not warn if the signed quantity is an unsuffixed integer literal (or some static constant expression involving such literals) and it is non-negative. */ - else if ((unsigned_op2 && tree_expr_nonnegative_p (op1)) - || (unsigned_op1 && tree_expr_nonnegative_p (op2))) + else if ((unsigned_op2 && c_tree_expr_nonnegative_p (op1)) + || (unsigned_op1 && c_tree_expr_nonnegative_p (op2))) /* OK */; else warning ("signed and unsigned type in conditional expression"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 18696d09e52..d382457b3bc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-09-07 Ansgar Esztermann + + * gcc.dg/compare2.c: Remove xfail from cases 10 and 12. + 2002-09-05 Ziemowit Laski * objc.dg/proto-lossage-1.m: New test. @@ -80,7 +84,7 @@ Tue Aug 27 22:23:22 2002 Nicola Pero 2002-08-26 Ziemowit Laski - * objc.dg/super-class-2.m: New test. + * objc.dg/super-class-2.m: New test. 2002-08-24 Matt Austern @@ -186,7 +190,7 @@ Tue Aug 27 22:23:22 2002 Nicola Pero 2002-08-06 Aldy Hernandez - * testsuite/gcc.dg/tls/diag-3.c: New. + * testsuite/gcc.dg/tls/diag-3.c: New. 2002-08-07 Gabriel Dos Reis @@ -231,7 +235,7 @@ Tue Aug 27 22:23:22 2002 Nicola Pero 2002-08-01 Benjamin Kosnik - * g++.old-deja/g++.abi/ptrflags.C (expect): Change + * g++.old-deja/g++.abi/ptrflags.C (expect): Change __qualifier_flags to __flags. 2002-07-31 Mark Mitchell diff --git a/gcc/testsuite/gcc.dg/compare2.c b/gcc/testsuite/gcc.dg/compare2.c index a33e4aa2955..0625eb9c3f6 100644 --- a/gcc/testsuite/gcc.dg/compare2.c +++ b/gcc/testsuite/gcc.dg/compare2.c @@ -26,11 +26,11 @@ void f(int x, unsigned int y) /* Statement expression. */ x > ({tf; 64;}); /* { dg-bogus "signed and unsigned" "case 9" } */ - y > ({tf; 64;}); /* { dg-bogus "signed and unsigned" "case 10" { xfail *-*-* } } */ + y > ({tf; 64;}); /* { dg-bogus "signed and unsigned" "case 10" } */ /* Statement expression with recursive ?: . */ x > ({tf; tf?64:(tf?128:256);}); /* { dg-bogus "signed and unsigned" "case 11" } */ - y > ({tf; tf?64:(tf?128:256);}); /* { dg-bogus "signed and unsigned" "case 12" { xfail *-*-* } } */ + y > ({tf; tf?64:(tf?128:256);}); /* { dg-bogus "signed and unsigned" "case 12" } */ /* Statement expression with signed ?:. */ x > ({tf; tf?64:-1;}); /* { dg-bogus "signed and unsigned" "case 13" } */ -- 2.30.2