From: Manuel López-Ibáñez Date: Wed, 20 Aug 2008 16:05:58 +0000 (+0000) Subject: re PR c++/35602 (Bogus warning with -Wsign-conversion) X-Git-Tag: releases/gcc-4.4.0~3008 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0011dedbd9dbfa01b2f4d3390ef3ed2d6ea1dd6d;p=thirdparty%2Fgcc.git re PR c++/35602 (Bogus warning with -Wsign-conversion) 2008-08-20 Manuel Lopez-Ibanez PR c++/35602 * c-common.c (conversion_warning): Do not warn for artificial expressions. testsuite/ * g++.dg/warn/pr35602.C: New. From-SVN: r139328 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a8e04a922648..9560a7bcc545 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-08-20 Manuel Lopez-Ibanez + + PR c++/35602 + * c-common.c (conversion_warning): Do not warn for artificial + expressions. + 2008-08-20 Richard Guenther * tree-vrp.c (op_with_constant_singleton_value_range): New function. diff --git a/gcc/c-common.c b/gcc/c-common.c index 639601d4fcdb..92e58c9fb00d 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 f20a46e45d5c..2c87d83e5ea6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-08-20 Manuel Lopez-Ibanez + + PR c++/35602 + * g++.dg/warn/pr35602.C: New. + 2008-08-20 Richard Guenther * 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 000000000000..66a569b3d272 --- /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; +}