]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/35602 (Bogus warning with -Wsign-conversion)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Wed, 20 Aug 2008 16:05:58 +0000 (16:05 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Wed, 20 Aug 2008 16:05:58 +0000 (16:05 +0000)
2008-08-20  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

PR c++/35602
* c-common.c (conversion_warning): Do not warn for artificial
expressions.
testsuite/
* g++.dg/warn/pr35602.C: New.

From-SVN: r139328

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pr35602.C [new file with mode: 0644]

index a8e04a9226489ecf8fb3c5cafe4feaee744ae140..9560a7bcc545d912c57eaa074232ba117b7e7267 100644 (file)
@@ -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.
index 639601d4fcdb25d604a3a2f6c1650a65ea8f3039..92e58c9fb00d8e44f219a4d535a4c3956c47f106 100644 (file)
@@ -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:
index f20a46e45d5c61a75d8a4126122223ff7e7c4cf6..2c87d83e5ea6b305881156299c8e774de0c9293b 100644 (file)
@@ -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 (file)
index 0000000..66a569b
--- /dev/null
@@ -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;
+}