diff options
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-common.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/pr35602.C | 28 |
4 files changed, 50 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a8e04a9..9560a7b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-08-20 Manuel Lopez-Ibanez <manu@gcc.gnu.org> + + PR c++/35602 + * c-common.c (conversion_warning): Do not warn for artificial + expressions. + 2008-08-20 Richard Guenther <rguenther@suse.de> * tree-vrp.c (op_with_constant_singleton_value_range): New function. diff --git a/gcc/c-common.c b/gcc/c-common.c index 639601d..92e58c9 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -1556,11 +1556,22 @@ conversion_warning (tree type, tree expr) { bool give_warning = false; + int i; + const int expr_num_operands = TREE_OPERAND_LENGTH (expr); tree expr_type = TREE_TYPE (expr); if (!warn_conversion && !warn_sign_conversion) return; + /* If any operand is artificial, then this expression was generated + by the compiler and we do not warn. */ + for (i = 0; i < expr_num_operands; i++) + { + tree op = TREE_OPERAND (expr, i); + if (DECL_P (op) && DECL_ARTIFICIAL (op)) + return; + } + switch (TREE_CODE (expr)) { case EQ_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f20a46e..2c87d83 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-08-20 Manuel Lopez-Ibanez <manu@gcc.gnu.org> + + PR c++/35602 + * g++.dg/warn/pr35602.C: New. + 2008-08-20 Richard Guenther <rguenther@suse.de> * gcc.dg/tree-ssa/pr21829.c: Scan optimized and cddce2 dumps diff --git a/gcc/testsuite/g++.dg/warn/pr35602.C b/gcc/testsuite/g++.dg/warn/pr35602.C new file mode 100644 index 0000000..66a569b --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr35602.C @@ -0,0 +1,28 @@ +// PR 35602 Bogus warning with -Wsign-conversion +// { dg-do compile } +// { dg-options "-Wconversion -Wsign-conversion" } +struct c +{ + ~c(); + c(); +}; + +int + +main(const int, + const char * const * const) +{ + c x[0UL][0UL] = // { dg-bogus "warning: conversion to .long unsigned int. from .long int. may change the sign of the result" } + { + }; + + c y[0UL] = + { + }; + + int z[0ul][0UL] = + { + }; + + return 0; +} |