OSDN Git Service

/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Oct 2011 20:01:31 +0000 (20:01 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Oct 2011 20:01:31 +0000 (20:01 +0000)
2011-10-21  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/45385
* init.c (build_vec_init): Early return error_mark_node if
maxindex is -1.

/c-family
2011-10-21  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/45385
* c-common.c (conversion_warning): Remove code looking for
artificial operands.

/testsuite
2011-10-21  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/45385
* g++.dg/warn/Wconversion4.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180312 138bc75d-0d04-0410-961f-82ee72b054a4

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

index d0bcf0f..706b273 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/45385
+       * c-common.c (conversion_warning): Remove code looking for
+       artificial operands.
+
 2011-10-18  Dodji Seketeli  <dodji@redhat.com>
 
        PR bootstrap/50760
index 9d20d80..ae18de3 100644 (file)
@@ -2121,23 +2121,12 @@ unsafe_conversion_p (tree type, tree expr, bool produce_warns)
 static void
 conversion_warning (tree type, tree expr)
 {
-  int i;
-  const int expr_num_operands = TREE_OPERAND_LENGTH (expr);
   tree expr_type = TREE_TYPE (expr);
   location_t loc = EXPR_LOC_OR_HERE (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 (op && DECL_P (op) && DECL_ARTIFICIAL (op))
-       return;
-    }
-
   switch (TREE_CODE (expr))
     {
     case EQ_EXPR:
index b58ee15..f3eea05 100644 (file)
@@ -1,5 +1,11 @@
 2011-10-21  Paolo Carlini  <paolo.carlini@oracle.com>
 
+       PR c++/45385
+       * init.c (build_vec_init): Early return error_mark_node if
+       maxindex is -1.
+
+2011-10-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
        PR c++/31423
        * typeck2.c (cxx_incomplete_type_diagnostic): Improve error message
        for invalid use of member function.
index 4561979..9115df3 100644 (file)
@@ -2998,7 +2998,8 @@ build_vec_init (tree base, tree maxindex, tree init,
   if (TREE_CODE (atype) == ARRAY_TYPE && TYPE_DOMAIN (atype))
     maxindex = array_type_nelts (atype);
 
-  if (maxindex == NULL_TREE || maxindex == error_mark_node)
+  if (maxindex == NULL_TREE || maxindex == error_mark_node
+      || integer_all_onesp (maxindex))
     return error_mark_node;
 
   if (explicit_value_init_p)
index 85aff91..71aa33d 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/45385
+       * g++.dg/warn/Wconversion4.C: New.
+
 2011-10-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/50813
diff --git a/gcc/testsuite/g++.dg/warn/Wconversion4.C b/gcc/testsuite/g++.dg/warn/Wconversion4.C
new file mode 100644 (file)
index 0000000..83daaa0
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/45385
+// { dg-options "-Wconversion" } 
+
+void foo(unsigned char);
+
+class Test
+{
+  void eval()
+  {
+    foo(bar());  // { dg-warning "may alter its value" }
+  }
+
+  unsigned int bar() const
+  {
+    return __INT_MAX__ * 2U + 1;
+  }
+};