]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c/80731 - poor -Woverflow warnings
authorMartin Sebor <msebor@redhat.com>
Wed, 24 May 2017 22:07:21 +0000 (22:07 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Wed, 24 May 2017 22:07:21 +0000 (16:07 -0600)
gcc/c-family/ChangeLog:

PR c/80731
* c-common.h (unsafe_conversion_p): Add a function argument.
* c-common.c (unsafe_conversion_p): Same.
Add type names and values to diagnostics.
(scalar_to_vector): Adjust.
* c-warn.c (constant_expression_error): Add a function argument.
Add type names and values to diagnostics.
(conversion_warning): Add a function argument.
Add type names and values to diagnostics.
(warnings_for_convert_and_check): Same.

gcc/c/ChangeLog:

PR c/80731
* c-fold.c (c_fully_fold_internal): Adjust.
* c-typeck.c (parser_build_unary_op): Adjust.

gcc/cp/ChangeLog:

PR c/80731
* call.c (fully_fold_internal): Adjust.

gcc/testsuite/ChangeLog:

PR c/80731
* c-c++-common/Wfloat-conversion.c: Adjust.
* c-c++-common/dfp/convert-int-saturate.c: Same.
* c-c++-common/pr68657-1.c: Same.
* g++.dg/ext/utf-cvt.C: Same.
* g++.dg/ext/utf16-4.C: Same.
* g++.dg/warn/Wconversion-real-integer-3.C: Same.
* g++.dg/warn/Wconversion-real-integer2.C: Same.
* g++.dg/warn/Wconversion3.C: Same.
* g++.dg/warn/Wconversion4.C: Same.
* g++.dg/warn/Wsign-conversion.C: Same.
* g++.dg/warn/overflow-warn-1.C: Same.
* g++.dg/warn/overflow-warn-3.C: Same.
* g++.dg/warn/overflow-warn-4.C: Same.
* g++.dg/warn/pr35635.C: Same.
* g++.old-deja/g++.mike/enum1.C: Same.
* gcc.dg/Wconversion-3.c: Same.
* gcc.dg/Wconversion-5.c: Same.
* gcc.dg/Wconversion-complex-c99.c: Same.
* gcc.dg/Wconversion-complex-gnu.c: Same.
* gcc.dg/Wconversion-integer.c: Same.
* gcc.dg/Wsign-conversion.c: Same.
* gcc.dg/bitfld-2.c: Same.
* gcc.dg/c90-const-expr-11.c: Same.
* gcc.dg/c90-const-expr-7.c: Same.
* gcc.dg/c99-const-expr-7.c: Same.
* gcc.dg/overflow-warn-1.c: Same.
* gcc.dg/overflow-warn-2.c: Same.
* gcc.dg/overflow-warn-3.c: Same.
* gcc.dg/overflow-warn-4.c: Same.
* gcc.dg/overflow-warn-5.c: Same.
* gcc.dg/overflow-warn-8.c: Same.
* gcc.dg/overflow-warn-9.c: New test.
* gcc.dg/pr35635.c: Adjust.
* gcc.dg/pr59940.c: Same.
* gcc.dg/pr59963-2.c: Same.
* gcc.dg/pr60114.c: Same.
* gcc.dg/switch-warn-2.c: Same.
* gcc.dg/utf-cvt.c: Same.
* gcc.dg/utf16-4.c: Same.

From-SVN: r248431

49 files changed:
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c-family/c-warn.c
gcc/c/ChangeLog
gcc/c/c-fold.c
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wfloat-conversion.c
gcc/testsuite/c-c++-common/dfp/convert-int-saturate.c
gcc/testsuite/c-c++-common/pr68657-1.c
gcc/testsuite/g++.dg/ext/utf-cvt.C
gcc/testsuite/g++.dg/ext/utf16-4.C
gcc/testsuite/g++.dg/warn/Wconversion-real-integer-3.C
gcc/testsuite/g++.dg/warn/Wconversion-real-integer2.C
gcc/testsuite/g++.dg/warn/Wconversion3.C
gcc/testsuite/g++.dg/warn/Wconversion4.C
gcc/testsuite/g++.dg/warn/Wsign-conversion.C
gcc/testsuite/g++.dg/warn/overflow-warn-1.C
gcc/testsuite/g++.dg/warn/overflow-warn-3.C
gcc/testsuite/g++.dg/warn/overflow-warn-4.C
gcc/testsuite/g++.dg/warn/pr35635.C
gcc/testsuite/g++.old-deja/g++.mike/enum1.C
gcc/testsuite/gcc.dg/Wconversion-3.c
gcc/testsuite/gcc.dg/Wconversion-5.c
gcc/testsuite/gcc.dg/Wconversion-complex-c99.c
gcc/testsuite/gcc.dg/Wconversion-complex-gnu.c
gcc/testsuite/gcc.dg/Wconversion-integer.c
gcc/testsuite/gcc.dg/Wsign-conversion.c
gcc/testsuite/gcc.dg/bitfld-2.c
gcc/testsuite/gcc.dg/c90-const-expr-11.c
gcc/testsuite/gcc.dg/c90-const-expr-7.c
gcc/testsuite/gcc.dg/c99-const-expr-7.c
gcc/testsuite/gcc.dg/overflow-warn-1.c
gcc/testsuite/gcc.dg/overflow-warn-2.c
gcc/testsuite/gcc.dg/overflow-warn-3.c
gcc/testsuite/gcc.dg/overflow-warn-4.c
gcc/testsuite/gcc.dg/overflow-warn-5.c
gcc/testsuite/gcc.dg/overflow-warn-8.c
gcc/testsuite/gcc.dg/overflow-warn-9.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr35635.c
gcc/testsuite/gcc.dg/pr59940.c
gcc/testsuite/gcc.dg/pr59963-2.c
gcc/testsuite/gcc.dg/pr60114.c
gcc/testsuite/gcc.dg/switch-warn-2.c
gcc/testsuite/gcc.dg/utf-cvt.c
gcc/testsuite/gcc.dg/utf16-4.c

index 4419f207e5c80367a0cea35c1f88719244e53407..83c000baabd6db9d98ab5ede005173ca96beb5d4 100644 (file)
@@ -1,3 +1,16 @@
+2017-05-24  Martin Sebor  <msebor@redhat.com>
+
+       PR c/80731
+       * c-common.h (unsafe_conversion_p): Add a function argument.
+       * c-common.c (unsafe_conversion_p): Same.
+       Add type names and values to diagnostics.
+       (scalar_to_vector): Adjust.
+       * c-warn.c (constant_expression_error): Add a function argument.
+       Add type names and values to diagnostics.
+       (conversion_warning): Add a function argument.
+       Add type names and values to diagnostics.
+       (warnings_for_convert_and_check): Same.
+
 2017-05-19  Jason Merrill  <jason@redhat.com>
 
        * c-warn.c (match_case_to_enum_1): Don't warn about enums with no
index 5f4488a908064cfa92797c6a670d3778d6da11bf..708fbe519196b57b80bfe311ff7a431bafcf6c9d 100644 (file)
@@ -1227,16 +1227,24 @@ int_safely_convertible_to_real_p (const_tree from_type, const_tree to_type)
    can return SAFE_CONVERSION (zero) in that case.  Function can produce
    signedness warnings if PRODUCE_WARNS is true.
 
+   RESULT, when non-null is the result of the conversion.  When constant
+   it is included in the text of diagnostics.
+
    Function allows conversions from complex constants to non-complex types,
    provided that imaginary part is zero and real part can be safely converted
    to TYPE.  */
 
 enum conversion_safety
-unsafe_conversion_p (location_t loc, tree type, tree expr, bool produce_warns)
+unsafe_conversion_p (location_t loc, tree type, tree expr, tree result,
+                    bool produce_warns)
 {
   enum conversion_safety give_warning = SAFE_CONVERSION; /* is 0 or false */
   tree expr_type = TREE_TYPE (expr);
-  loc = expansion_point_location_if_in_system_header (loc);
+
+  bool cstresult = (result
+                   && TREE_CODE_CLASS (TREE_CODE (result)) == tcc_constant);
+
+    loc = expansion_point_location_if_in_system_header (loc);
 
   if (TREE_CODE (expr) == REAL_CST || TREE_CODE (expr) == INTEGER_CST)
     {
@@ -1262,14 +1270,31 @@ unsafe_conversion_p (location_t loc, tree type, tree expr, bool produce_warns)
              && tree_int_cst_sgn (expr) < 0)
            {
              if (produce_warns)
-               warning_at (loc, OPT_Wsign_conversion, "negative integer"
-                           " implicitly converted to unsigned type");
+               {
+                 if (cstresult)
+                   warning_at (loc, OPT_Wsign_conversion,
+                               "unsigned conversion from %qT to %qT "
+                               "changes value from %qE to %qE",
+                               expr_type, type, expr, result);
+                 else
+                   warning_at (loc, OPT_Wsign_conversion,
+                               "unsigned conversion from %qT to %qT "
+                               "changes the value of %qE",
+                               expr_type, type, expr);
+               }
            }
          else if (!TYPE_UNSIGNED (type) && TYPE_UNSIGNED (expr_type))
            {
-             if (produce_warns)
-               warning_at (loc, OPT_Wsign_conversion, "conversion of unsigned"
-                           " constant value to negative integer");
+             if (cstresult)
+               warning_at (loc, OPT_Wsign_conversion,
+                           "signed conversion from %qT to %qT changes "
+                           "value from %qE to %qE",
+                           expr_type, type, expr, result);
+             else
+               warning_at (loc, OPT_Wsign_conversion,
+                           "signed conversion from %qT to %qT changes "
+                           "the value of %qE",
+                           expr_type, type, expr);
            }
          else
            give_warning = UNSAFE_OTHER;
@@ -1308,7 +1333,7 @@ unsafe_conversion_p (location_t loc, tree type, tree expr, bool produce_warns)
           with different type of EXPR, but it is still safe, because when EXPR
           is a constant, it's type is not used in text of generated warnings
           (otherwise they could sound misleading).  */
-       return unsafe_conversion_p (loc, type, TREE_REALPART (expr),
+       return unsafe_conversion_p (loc, type, TREE_REALPART (expr), result,
                                    produce_warns);
       /* Conversion from complex constant with non-zero imaginary part.  */
       else
@@ -1328,9 +1353,10 @@ unsafe_conversion_p (location_t loc, tree type, tree expr, bool produce_warns)
                 Possible solution: add a separate function for checking
                 constants and combine result of two calls appropriately.  */
              enum conversion_safety re_safety =
-                 unsafe_conversion_p (loc, type, TREE_REALPART (expr), false);
+                 unsafe_conversion_p (loc, type, TREE_REALPART (expr),
+                                      result, false);
              enum conversion_safety im_safety =
-                 unsafe_conversion_p (loc, type, imag_part, false);
+               unsafe_conversion_p (loc, type, imag_part, result, false);
 
              /* Merge the results into appropriate single warning.  */
 
@@ -7654,7 +7680,8 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1,
        if (TREE_CODE (type0) == INTEGER_TYPE
            && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE)
          {
-           if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0, false))
+           if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0,
+                                    NULL_TREE, false))
              {
                if (complain)
                  error_at (loc, "conversion of scalar %qT to vector %qT "
@@ -7702,7 +7729,8 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1,
        if (TREE_CODE (type0) == INTEGER_TYPE
            && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE)
          {
-           if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0, false))
+           if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0,
+                                    NULL_TREE, false))
              {
                if (complain)
                  error_at (loc, "conversion of scalar %qT to vector %qT "
@@ -7717,7 +7745,8 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1,
                     || TREE_CODE (type0) == INTEGER_TYPE)
                 && SCALAR_FLOAT_TYPE_P (TREE_TYPE (type1)))
          {
-           if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0, false))
+           if (unsafe_conversion_p (loc, TREE_TYPE (type1), op0,
+                                    NULL_TREE, false))
              {
                if (complain)
                  error_at (loc, "conversion of scalar %qT to vector %qT "
index 502dc2f95cd1d5946396d51dd213780f92856844..79072e6a8b74be883f9794a27996e9210cafc605 100644 (file)
@@ -832,7 +832,7 @@ extern tree c_common_signed_type (tree);
 extern tree c_common_signed_or_unsigned_type (int, tree);
 extern void c_common_init_ts (void);
 extern tree c_build_bitfield_integer_type (unsigned HOST_WIDE_INT, int);
-extern enum conversion_safety unsafe_conversion_p (location_t, tree, tree,
+extern enum conversion_safety unsafe_conversion_p (location_t, tree, tree, tree,
                                                   bool);
 extern bool decl_with_nonnull_addr_p (const_tree);
 extern tree c_fully_fold (tree, bool, bool *);
@@ -1483,7 +1483,7 @@ extern bool cilk_recognize_spawn (tree, tree *);
 /* In c-warn.c.  */
 extern void constant_expression_warning (tree);
 extern void constant_expression_error (tree);
-extern void overflow_warning (location_t, tree);
+extern void overflow_warning (location_t, tree, tree = NULL_TREE);
 extern void warn_logical_operator (location_t, enum tree_code, tree,
                                   enum tree_code, tree, enum tree_code, tree);
 extern void warn_tautological_cmp (location_t, enum tree_code, tree, tree);
index 897115612a0b73e2d0cb8a025cbc41e3237e7d75..012675bf6e9ae88d1d6797f7400e79d2b8b885ef 100644 (file)
@@ -63,8 +63,9 @@ constant_expression_error (tree value)
     error ("overflow in constant expression");
 }
 
-/* Print a warning if an expression had overflow in folding and its
-   operands hadn't.
+/* Print a warning if an expression result VALUE had an overflow
+   in folding and its operands hadn't.  EXPR, which may be null, is
+   the operand of the expression.
 
    Invoke this function on every expression that
    (1) appears in the source code, and
@@ -75,42 +76,74 @@ constant_expression_error (tree value)
    already overflowed.  */
 
 void
-overflow_warning (location_t loc, tree value)
+overflow_warning (location_t loc, tree value, tree expr)
 {
   if (c_inhibit_evaluation_warnings != 0)
     return;
 
+  const char *warnfmt = NULL;
+
   switch (TREE_CODE (value))
     {
     case INTEGER_CST:
-      warning_at (loc, OPT_Woverflow, "integer overflow in expression");
+      warnfmt = (expr
+                ? G_("integer overflow in expression %qE of type %qT "
+                     "results in %qE")
+                : G_("integer overflow in expression of type %qT "
+                     "results in %qE"));
       break;
 
     case REAL_CST:
-      warning_at (loc, OPT_Woverflow,
-                 "floating point overflow in expression");
+      warnfmt = (expr
+                ? G_ ("floating point overflow in expression %qE "
+                      "of type %qT results in %qE")
+                : G_ ("floating point overflow in expression of type %qT "
+                      "results in %qE"));
       break;
 
     case FIXED_CST:
-      warning_at (loc, OPT_Woverflow, "fixed-point overflow in expression");
+      warnfmt = (expr
+                ? G_("fixed-point overflow in expression %qE of type %qT "
+                     "results in %qE")
+                : G_("fixed-point overflow in expression of type %qT "
+                     "results in %qE"));
       break;
 
     case VECTOR_CST:
-      warning_at (loc, OPT_Woverflow, "vector overflow in expression");
+      warnfmt = (expr
+                ? G_("vector overflow in expression %qE of type %qT "
+                     "results in %qE")
+                : G_("vector overflow in expression of type %qT "
+                     "results in %qE"));
       break;
 
     case COMPLEX_CST:
       if (TREE_CODE (TREE_REALPART (value)) == INTEGER_CST)
-       warning_at (loc, OPT_Woverflow,
-                   "complex integer overflow in expression");
+       warnfmt = (expr
+                  ? G_("complex integer overflow in expression %qE "
+                       "of type %qT results in %qE")
+                  : G_("complex integer overflow in expression of type %qT "
+                       "results in %qE"));
       else if (TREE_CODE (TREE_REALPART (value)) == REAL_CST)
-       warning_at (loc, OPT_Woverflow,
-                   "complex floating point overflow in expression");
+       warnfmt = (expr
+                  ? G_("complex floating point overflow in expression %qE "
+                       "of type %qT results in %qE")
+                  : G_("complex floating point overflow in expression "
+                       "of type %qT results in %qE"));
+      else
+       return;
       break;
 
     default:
-      break;
+      return;
     }
+
+  if (expr)
+    warning_at (loc, OPT_Woverflow, warnfmt, expr, TREE_TYPE (expr), value);
+  else
+    warning_at (loc, OPT_Woverflow, warnfmt, TREE_TYPE (value), value);
+
+  TREE_NO_WARNING (value) = 1;
 }
 
 /* Helper function for walk_tree.  Unwrap C_MAYBE_CONST_EXPRs in an expression
@@ -930,7 +963,7 @@ check_main_parameter_types (tree decl)
    This is a helper function for warnings_for_convert_and_check.  */
 
 static void
-conversion_warning (location_t loc, tree type, tree expr)
+conversion_warning (location_t loc, tree type, tree expr, tree result)
 {
   tree expr_type = TREE_TYPE (expr);
   enum conversion_safety conversion_kind;
@@ -971,43 +1004,49 @@ conversion_warning (location_t loc, tree type, tree expr)
     case REAL_CST:
     case INTEGER_CST:
     case COMPLEX_CST:
-      conversion_kind = unsafe_conversion_p (loc, type, expr, true);
-      if (conversion_kind == UNSAFE_REAL)
-       warning_at (loc, OPT_Wfloat_conversion,
-                   "conversion to %qT alters %qT constant value",
-                   type, expr_type);
-      else if (conversion_kind)
-       warning_at (loc, OPT_Wconversion,
-                   "conversion to %qT alters %qT constant value",
-                   type, expr_type);
-      return;
+      {
+       conversion_kind = unsafe_conversion_p (loc, type, expr, result, true);
+       int warnopt;
+       if (conversion_kind == UNSAFE_REAL)
+         warnopt = OPT_Wfloat_conversion;
+       else if (conversion_kind)
+         warnopt = OPT_Wconversion;
+       else
+         break;
 
+       if (TREE_CODE_CLASS (TREE_CODE (result)) == tcc_constant)
+         warning_at (loc, warnopt,
+                     "conversion from %qT to %qT changes value from %qE to %qE",
+                     expr_type, type, expr, result);
+       else
+         warning_at (loc, warnopt,
+                     "conversion from %qT to %qT changes the value of %qE",
+                     expr_type, type, expr);
+       break;
+      }
     case COND_EXPR:
-      {
+         {
        /* In case of COND_EXPR, we do not care about the type of
           COND_EXPR, only about the conversion of each operand.  */
        tree op1 = TREE_OPERAND (expr, 1);
        tree op2 = TREE_OPERAND (expr, 2);
 
-       conversion_warning (loc, type, op1);
-       conversion_warning (loc, type, op2);
+       conversion_warning (loc, type, op1, result);
+       conversion_warning (loc, type, op2, result);
        return;
       }
 
     default: /* 'expr' is not a constant.  */
-      conversion_kind = unsafe_conversion_p (loc, type, expr, true);
-      if (conversion_kind == UNSAFE_REAL)
-       warning_at (loc, OPT_Wfloat_conversion,
-                   "conversion to %qT from %qT may alter its value",
-                   type, expr_type);
-      else if (conversion_kind == UNSAFE_IMAGINARY)
-       warning_at (loc, OPT_Wconversion,
-                   "conversion to %qT from %qT discards imaginary component",
-                   type, expr_type);
-      else if (conversion_kind)
+      conversion_kind = unsafe_conversion_p (loc, type, expr, result, true);
+      if (conversion_kind == UNSAFE_IMAGINARY)
        warning_at (loc, OPT_Wconversion,
-                   "conversion to %qT from %qT may alter its value",
-                   type, expr_type);
+                   "conversion from %qT to to %qT discards imaginary "
+                   "component",
+                   expr_type, type);
+      else if (conversion_kind == UNSAFE_REAL || conversion_kind)
+       warning_at (loc, OPT_Wfloat_conversion,
+                   "conversion from %qT to %qT may change value",
+                   expr_type, type);
     }
 }
 
@@ -1021,6 +1060,10 @@ warnings_for_convert_and_check (location_t loc, tree type, tree expr,
 {
   loc = expansion_point_location_if_in_system_header (loc);
 
+  bool cst = TREE_CODE_CLASS (TREE_CODE (result)) == tcc_constant;
+
+  tree exprtype = TREE_TYPE (expr);
+
   if (TREE_CODE (expr) == INTEGER_CST
       && (TREE_CODE (type) == INTEGER_TYPE
          || TREE_CODE (type) == ENUMERAL_TYPE)
@@ -1036,31 +1079,76 @@ warnings_for_convert_and_check (location_t loc, tree type, tree expr,
          /* This detects cases like converting -129 or 256 to
             unsigned char.  */
          if (!int_fits_type_p (expr, c_common_signed_type (type)))
-           warning_at (loc, OPT_Woverflow,
-                       "large integer implicitly truncated to unsigned type");
+           {
+             if (cst)
+               warning_at (loc, OPT_Woverflow,
+                           (TYPE_UNSIGNED (exprtype)
+                            ? G_("conversion from %qT to %qT "
+                                 "changes value from %qE to %qE")
+                            : G_("unsigned conversion from %qT to %qT "
+                                 "changes value from %qE to %qE")),
+                           exprtype, type, expr, result);
+             else
+               warning_at (loc, OPT_Woverflow,
+                           (TYPE_UNSIGNED (exprtype)
+                            ? G_("conversion from %qT to %qT "
+                                 "changes the value of %qE")
+                            : G_("unsigned conversion from %qT to %qT "
+                                 "changes the value of %qE")),
+                           exprtype, type, expr);
+           }
          else
-           conversion_warning (loc, type, expr);
+           conversion_warning (loc, type, expr, result);
        }
       else if (!int_fits_type_p (expr, c_common_unsigned_type (type)))
-       warning_at (loc, OPT_Woverflow,
-                "overflow in implicit constant conversion");
+       {
+         if (cst)
+           warning_at (loc, OPT_Woverflow,
+                       "overflow in conversion from %qT to %qT "
+                       "changes value from %qE to %qE",
+                       exprtype, type, expr, result);
+         else
+           warning_at (loc, OPT_Woverflow,
+                       "overflow in conversion from %qT to %qT "
+                       "changes the value of %qE",
+                       exprtype, type, expr);
+       }
       /* No warning for converting 0x80000000 to int.  */
       else if (pedantic
-              && (TREE_CODE (TREE_TYPE (expr)) != INTEGER_TYPE
-                  || TYPE_PRECISION (TREE_TYPE (expr))
+              && (TREE_CODE (exprtype) != INTEGER_TYPE
+                  || TYPE_PRECISION (exprtype)
                   != TYPE_PRECISION (type)))
-       warning_at (loc, OPT_Woverflow,
-                   "overflow in implicit constant conversion");
-
+       {
+         if (cst)
+           warning_at (loc, OPT_Woverflow,
+                       "overflow in conversion from %qT to %qT "
+                       "changes value from %qE to %qE",
+                       exprtype, type, expr, result);
+         else
+           warning_at (loc, OPT_Woverflow,
+                       "overflow in conversion from %qT to %qT "
+                       "changes the value of %qE",
+                       exprtype, type, expr);
+       }
       else
-       conversion_warning (loc, type, expr);
+       conversion_warning (loc, type, expr, result);
     }
   else if ((TREE_CODE (result) == INTEGER_CST
            || TREE_CODE (result) == FIXED_CST) && TREE_OVERFLOW (result))
-    warning_at (loc, OPT_Woverflow,
-               "overflow in implicit constant conversion");
+    {
+      if (cst)
+       warning_at (loc, OPT_Woverflow,
+                   "overflow in conversion from %qT to %qT "
+                   "chages value from %qE to %qE",
+                   exprtype, type, expr, result);
+      else
+       warning_at (loc, OPT_Woverflow,
+                   "overflow in conversion from %qT to %qT "
+                   "chages the value of %qE",
+                   exprtype, type, expr);
+    }
   else
-    conversion_warning (loc, type, expr);
+    conversion_warning (loc, type, expr, result);
 }
 
 /* Subroutines of c_do_switch_warnings, called via splay_tree_foreach.
index cb04d4acb5a9a51bad97f42a74f36ad035d5fabf..d240298d4d8fd42f0efb5d4470a2d7919a412505 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-24  Martin Sebor  <msebor@redhat.com>
+
+       PR c/80731
+       * c-fold.c (c_fully_fold_internal): Adjust.
+       * c-typeck.c (parser_build_unary_op): Adjust.
+
 2017-05-23  Thomas Schwinge  <thomas@codesourcery.com>
 
        * c-parser.c (OACC_KERNELS_CLAUSE_MASK): Add
index 2601224c84717ee6971a4c980b37b8c53800f989..0abc4acc37fb665ec4e839eed8cb70eaeb50e2d0 100644 (file)
@@ -307,7 +307,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
       if (TREE_OVERFLOW_P (ret)
          && !TREE_OVERFLOW_P (op0)
          && !TREE_OVERFLOW_P (op1))
-       overflow_warning (EXPR_LOC_OR_LOC (expr, input_location), ret);
+       overflow_warning (EXPR_LOC_OR_LOC (expr, input_location), ret, expr);
       if (code == LSHIFT_EXPR
          && TREE_CODE (orig_op0) != INTEGER_CST
          && TREE_CODE (TREE_TYPE (orig_op0)) == INTEGER_TYPE
@@ -428,7 +428,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
 
        default:
          if (TREE_OVERFLOW_P (ret) && !TREE_OVERFLOW_P (op0))
-           overflow_warning (EXPR_LOCATION (expr), ret);
+           overflow_warning (EXPR_LOCATION (expr), ret, op0);
          break;
        }
       goto out;
index 25b7dd60253b3b71997359633c5b20e267e099c4..95a607a1e76fa813e090123d763c7fe24d1ba28e 100644 (file)
@@ -3588,7 +3588,7 @@ parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg)
       result.value = build_unary_op (loc, code, arg.value, false);
 
       if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
-       overflow_warning (loc, result.value);
+       overflow_warning (loc, result.value, arg.value);
     }
 
   /* We are typically called when parsing a prefix token at LOC acting on
index 27716d3d382df3c5062ca99191bd12e15c80505c..f2828f8d7eb6181a3d1d2a492dafd94b3ba55107 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-24  Martin Sebor  <msebor@redhat.com>
+
+       PR c/80731
+       * call.c (fully_fold_internal): Adjust.
+
 2017-05-24  Nathan Sidwell  <nathan@acm.org>
 
        * cp-tree.h (ovl_skip_hidden): Declare.
index f14c0fabcc58b50894a7b76939255e59e8d226b7..6b13d6e4cd8a9d407bd9e8adbf733bfa12681552 100644 (file)
@@ -4814,14 +4814,14 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3,
             but the warnings (like Wsign-conversion) have already been
             given by the scalar build_conditional_expr_1. We still check
             unsafe_conversion_p to forbid truncating long long -> float.  */
-         if (unsafe_conversion_p (loc, stype, arg2, false))
+         if (unsafe_conversion_p (loc, stype, arg2, NULL_TREE, false))
            {
              if (complain & tf_error)
                error_at (loc, "conversion of scalar %qT to vector %qT "
                               "involves truncation", arg2_type, vtype);
              return error_mark_node;
            }
-         if (unsafe_conversion_p (loc, stype, arg3, false))
+         if (unsafe_conversion_p (loc, stype, arg3, NULL_TREE, false))
            {
              if (complain & tf_error)
                error_at (loc, "conversion of scalar %qT to vector %qT "
index 9308ae15ae8374c91b1642bceae6d191ee38e598..003dfa1b2d7bad337723668f7eed57205a33cb78 100644 (file)
@@ -1,3 +1,46 @@
+2017-05-24  Martin Sebor  <msebor@redhat.com>
+
+       PR c/80731
+       * c-c++-common/Wfloat-conversion.c: Adjust.
+       * c-c++-common/dfp/convert-int-saturate.c: Same.
+       * c-c++-common/pr68657-1.c: Same.
+       * g++.dg/ext/utf-cvt.C: Same.
+       * g++.dg/ext/utf16-4.C: Same.
+       * g++.dg/warn/Wconversion-real-integer-3.C: Same.
+       * g++.dg/warn/Wconversion-real-integer2.C: Same.
+       * g++.dg/warn/Wconversion3.C: Same.
+       * g++.dg/warn/Wconversion4.C: Same.
+       * g++.dg/warn/Wsign-conversion.C: Same.
+       * g++.dg/warn/overflow-warn-1.C: Same.
+       * g++.dg/warn/overflow-warn-3.C: Same.
+       * g++.dg/warn/overflow-warn-4.C: Same.
+       * g++.dg/warn/pr35635.C: Same.
+       * g++.old-deja/g++.mike/enum1.C: Same.
+       * gcc.dg/Wconversion-3.c: Same.
+       * gcc.dg/Wconversion-5.c: Same.
+       * gcc.dg/Wconversion-complex-c99.c: Same.
+       * gcc.dg/Wconversion-complex-gnu.c: Same.
+       * gcc.dg/Wconversion-integer.c: Same.
+       * gcc.dg/Wsign-conversion.c: Same.
+       * gcc.dg/bitfld-2.c: Same.
+       * gcc.dg/c90-const-expr-11.c: Same.
+       * gcc.dg/c90-const-expr-7.c: Same.
+       * gcc.dg/c99-const-expr-7.c: Same.
+       * gcc.dg/overflow-warn-1.c: Same.
+       * gcc.dg/overflow-warn-2.c: Same.
+       * gcc.dg/overflow-warn-3.c: Same.
+       * gcc.dg/overflow-warn-4.c: Same.
+       * gcc.dg/overflow-warn-5.c: Same.
+       * gcc.dg/overflow-warn-8.c: Same.
+       * gcc.dg/overflow-warn-9.c: New test.
+       * gcc.dg/pr35635.c: Adjust.
+       * gcc.dg/pr59940.c: Same.
+       * gcc.dg/pr59963-2.c: Same.
+       * gcc.dg/pr60114.c: Same.
+       * gcc.dg/switch-warn-2.c: Same.
+       * gcc.dg/utf-cvt.c: Same.
+       * gcc.dg/utf16-4.c: Same.
+
 2017-05-24  Jakub Jelinek  <jakub@redhat.com>
 
        * g++.dg/ext/integer-pack2.C: Require int32 effective target.
index e872755902deeab3081e2cabe26acfc35c9d5b6e..e9899bce12b19340aaf364681932c3bfc6deeeef 100644 (file)
@@ -29,30 +29,30 @@ void h (void)
   double d = 0;
   long double ld = 0;
 
-  ffloat (3.1); /* { dg-warning "conversion to 'float' alters 'double' constant value" } */
-  vfloat = 3.1; /* { dg-warning "conversion to 'float' alters 'double' constant value" } */
-  ffloat (3.1L); /* { dg-warning "conversion to 'float' alters 'long double' constant value" } */
-  vfloat = 3.1L;  /* { dg-warning "conversion to 'float' alters 'long double' constant value" } */
-  fdouble (3.1L); /* { dg-warning "conversion to 'double' alters 'long double' constant value" "" { target large_long_double } } */
-  vdouble = 3.1L; /* { dg-warning "conversion to 'double' alters 'long double' constant value" "" { target large_long_double } } */
-  ffloat (vdouble); /* { dg-warning "conversion to 'float' from 'double' may alter its value" } */
-  vfloat = vdouble; /* { dg-warning "conversion to 'float' from 'double' may alter its value" } */
-  ffloat (vlongdouble); /* { dg-warning "conversion to 'float' from 'long double' may alter its value" } */
-  vfloat = vlongdouble; /* { dg-warning "conversion to 'float' from 'long double' may alter its value" } */
-  fdouble (vlongdouble); /* { dg-warning "conversion to 'double' from 'long double' may alter its value" "" { target large_long_double } } */
-  vdouble = vlongdouble; /* { dg-warning "conversion to 'double' from 'long double' may alter its value" "" { target large_long_double } } */
+  ffloat (3.1); /* { dg-warning "conversion from .double. to .float. changes value" } */
+  vfloat = 3.1; /* { dg-warning "conversion from .double. to .float. changes value" } */
+  ffloat (3.1L); /* { dg-warning "conversion from .long double. to .float. changes value" } */
+  vfloat = 3.1L;  /* { dg-warning "conversion from .long double. to .float. changes value" } */
+  fdouble (3.1L); /* { dg-warning "conversion from .long double. to .double. changes value" "" { target large_long_double } } */
+  vdouble = 3.1L; /* { dg-warning "conversion from .long double. to .double. changes value" "" { target large_long_double } } */
+  ffloat (vdouble); /* { dg-warning "conversion from .double. to .float. may change value" } */
+  vfloat = vdouble; /* { dg-warning "conversion from .double. to .float. may change value" } */
+  ffloat (vlongdouble); /* { dg-warning "conversion from .long double. to .float. may change value" } */
+  vfloat = vlongdouble; /* { dg-warning "conversion from .long double. to .float. may change value" } */
+  fdouble (vlongdouble); /* { dg-warning "conversion from .long double. to .double. may change value" } */
+  vdouble = vlongdouble; /* { dg-warning "conversion from .long double. to .double. may change value" } */
 
-  fsi (3.1f); /* { dg-warning "conversion to 'int' alters 'float' constant value" } */
-  si = 3.1f; /* { dg-warning "conversion to 'int' alters 'float' constant value" } */
-  fsi (3.1);  /* { dg-warning "conversion to 'int' alters 'double' constant value" } */
-  si = 3.1;  /* { dg-warning "conversion to 'int' alters 'double' constant value" } */
-  fsi (d);    /* { dg-warning "conversion to 'int' from 'double' may alter its value" } */
-  si = d;    /* { dg-warning "conversion to 'int' from 'double' may alter its value" } */
-  ffloat (INT_MAX);  /* { dg-warning "conversion to 'float' alters 'int' constant value" } */
-  vfloat = INT_MAX;  /* { dg-warning "conversion to 'float' alters 'int' constant value" } */
-  ffloat (16777217); /* { dg-warning "conversion to 'float' alters 'int' constant value" } */
-  vfloat = 16777217; /* { dg-warning "conversion to 'float' alters 'int' constant value" } */
+  fsi (3.1f); /* { dg-warning "conversion from .float. to .int. changes value" } */
+  si = 3.1f; /* { dg-warning "conversion from .float. to .int. changes value" } */
+  fsi (3.1);  /* { dg-warning "conversion from .double. to .int. changes value" } */
+  si = 3.1;  /* { dg-warning "conversion from .double. to .int. changes value" } */
+  fsi (d);    /* { dg-warning "conversion from .double. to .int. may change value" } */
+  si = d;    /* { dg-warning "conversion from .double. to .int. may change value" } */
+  ffloat (INT_MAX);  /* { dg-warning "conversion from .int. to .float. changes value" } */
+  vfloat = INT_MAX;  /* { dg-warning "conversion from .int. to .float. changes value" } */
+  ffloat (16777217); /* { dg-warning "conversion from .int. to .float. changes value from .16777217." } */
+  vfloat = 16777217; /* { dg-warning "conversion from .int. to .float. changes value from .16777217." } */
 
-  sc = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion to 'signed char' alters 'double' constant value" } */
-  uc = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion to 'unsigned char' alters 'double' constant value" } */
+  sc = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion from .double. to .signed char. changes the value of .2\.1" } */
+  uc = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion from .double. to .unsigned char. changes the value of .2\.1" } */
 }
index c92502d56ad2068aa91bd11947af7fc9597c5aaf..2d01f99468bfb47f4e36dc4fd2bfe59d32f3e28e 100644 (file)
@@ -23,40 +23,40 @@ main ()
 {
 
   /* Unsigned.  */
-  usi = DEC32_MAX;  /* { dg-warning "overflow in implicit constant conversion" } */
+  usi = DEC32_MAX;  /* { dg-warning "overflow in conversion" } */
   if (usi != UINT_MAX)
     FAILURE
 
-  usi = DEC64_MAX;  /* { dg-warning "overflow in implicit constant conversion" } */
+  usi = DEC64_MAX;  /* { dg-warning "overflow in conversion" } */
   if (usi != UINT_MAX)
     FAILURE
 
-  usi = DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
+  usi = DEC128_MAX; /* { dg-warning "overflow in conversion" } */
   if (usi != UINT_MAX)
     FAILURE
 
   /* Signed.  */
-  si = DEC32_MAX;      /* { dg-warning "overflow in implicit constant conversion" } */
+  si = DEC32_MAX;      /* { dg-warning "overflow in conversion" } */
   if (si != INT_MAX)
     FAILURE
 
-  si = DEC64_MAX;   /* { dg-warning "overflow in implicit constant conversion" } */
+  si = DEC64_MAX;   /* { dg-warning "overflow in conversion" } */
   if (si != INT_MAX)
     FAILURE
 
-  si = DEC128_MAX;  /* { dg-warning "overflow in implicit constant conversion" } */
+  si = DEC128_MAX;  /* { dg-warning "overflow in conversion" } */
   if (si != INT_MAX)
     FAILURE
 
-  si = - DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
+  si = - DEC32_MAX; /* { dg-warning "overflow in conversion" } */
   if (si != INT_MIN)
     FAILURE
 
-  si = - DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
+  si = - DEC64_MAX; /* { dg-warning "overflow in conversion" } */
   if (si != INT_MIN)
     FAILURE
 
-  si = - DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
+  si = - DEC128_MAX; /* { dg-warning "overflow in conversion" } */
   if (si != INT_MIN)
     FAILURE
 
index 84f3e54a992f7def11a029fc37e8a90dc9fc2a3d..7b62b72e42d924e75136a6934cb2a665d1ba14c2 100644 (file)
@@ -5,14 +5,14 @@
 void
 f1 (void)
 {
-  unsigned int a = -5; /* { dg-error "negative integer implicitly converted to unsigned type" } */
+  unsigned int a = -5; /* { dg-error "unsigned conversion from .int. to .unsigned int. changes value from .-5. to .\[0-9\]+." } */
   (void) a;
 }
 
 int
 f2 (void)
 {
-  return 3.1f; /* { dg-error "conversion to 'int' alters 'float' constant value" } */
+  return 3.1f; /* { dg-error "conversion from .float. to .int. changes value" } */
 }
 
 int f3 (char *);
index 366c3d41796d0cfeecd796769c6e4ce81ba48bab..929b7c713039b9ff9830afe012c9eb3277a91417 100644 (file)
@@ -21,9 +21,9 @@ extern void full (unsigned long long);
 
 void m(char16_t c0, char32_t c1)
 {
-    f_c (c0);  /* { dg-warning "alter its value" } */
-    fsc (c0);  /* { dg-warning "alter its value" } */
-    fuc (c0);  /* { dg-warning "alter its value" } */
+    f_c (c0);  /* { dg-warning "conversion from .char16_t. to .char. may change value" } */
+    fsc (c0);  /* { dg-warning "change value" } */
+    fuc (c0);  /* { dg-warning "change value" } */
     f_s (c0);  /* { dg-warning "change the sign" } */
     fss (c0);  /* { dg-warning "change the sign" } */
     fus (c0);
@@ -37,12 +37,12 @@ void m(char16_t c0, char32_t c1)
     fsll (c0);
     full (c0);
 
-    f_c (c1);  /* { dg-warning "alter its value" } */
-    fsc (c1);  /* { dg-warning "alter its value" } */
-    fuc (c1);  /* { dg-warning "alter its value" } */
-    f_s (c1);  /* { dg-warning "alter its value" } */
-    fss (c1);  /* { dg-warning "alter its value" } */
-    fus (c1);  /* { dg-warning "alter its value" } */
+    f_c (c1);  /* { dg-warning "change value" } */
+    fsc (c1);  /* { dg-warning "change value" } */
+    fuc (c1);  /* { dg-warning "change value" } */
+    f_s (c1);  /* { dg-warning "change value" } */
+    fss (c1);  /* { dg-warning "change value" } */
+    fus (c1);  /* { dg-warning "change value" } */
     f_i (c1);  /* { dg-warning "change the sign" } */
     fsi (c1);  /* { dg-warning "change the sign" } */
     fui (c1);
index e8d6531b20d7a73e950f90aafbfe95b8adf62011..2c4377cea5d08d57e9c9cbbfb2f4af89149da684 100644 (file)
@@ -10,9 +10,9 @@ const static char16_t c2 = u'\U00064321';     /* { dg-warning "constant too long" }
 const static char16_t  c3 = 'a';
 const static char16_t  c4 = U'a';
 const static char16_t  c5 = U'\u2029';
-const static char16_t  c6 = U'\U00064321';     /* { dg-warning "implicitly truncated" } */
+const static char16_t  c6 = U'\U00064321';     /* { dg-warning "conversion from .char32_t. to .char16_t. changes value from .410401. to .17185." } */
 const static char16_t  c7 = L'a';
 const static char16_t  c8 = L'\u2029';
-const static char16_t  c9 = L'\U00064321';     /* { dg-warning "implicitly truncated" "" { target { 4byte_wchar_t } } } */
+const static char16_t  c9 = L'\U00064321';     /* { dg-warning "unsigned conversion from .wchar_t. to .char16_t. changes value from .410401. to .17185." "" { target { 4byte_wchar_t } } } */
                                                /* { dg-warning "constant too long" "" { target { ! 4byte_wchar_t } } .-1 } */
 int main () {}
index 775c88c3fade76b087a7f08b42ba8555dc255593..8b7574dbbc8c8a9e538c7a1713af074f7d67dd47 100644 (file)
@@ -16,5 +16,5 @@ void h (void)
     // the locus that inside the source code here, at the relevant
     // line below, even with -ftrack-macro-expansion.  We don't want
     // it to point to the any locus that is inside the system header.
-    vfloat = INT_MAX; // { dg-warning "conversion to .float. alters .int. constant value" }
+    vfloat = INT_MAX; // { dg-warning "conversion from .int. to .float. changes value from .2147483647. to " }
 }
index 7e39d5fa747e262eb969b6309094b2d9b4eabb5a..7386525ae84e2e76272d9db247c4f0a0d6c16e3c 100644 (file)
@@ -23,7 +23,7 @@
 //
 // That is more useful.
 
-#define INT_MAX __INT_MAX__ // { dg-warning "17: conversion to .float. alters .int. constant value" }
+#define INT_MAX __INT_MAX__ // { dg-warning "17: conversion from 'int' to 'float' changes value from .2147483647. to " }
 
 float  vfloat;
 
index 24202b7d98ea3d3fcaf5b31b148198156898f7e7..71604f9a8e65de0c13ba8685d9483e4847278d0e 100644 (file)
@@ -19,9 +19,9 @@ void test1 (void)
   unsigned char f = (int) uc;
   signed char g = (int) sc;
   unsigned char h = (unsigned int) (short int) uc;
-  signed char i = (int) (unsigned short int) sc;       // { dg-warning "may alter its value" }
-  unsigned char j = (unsigned int) (short int) us;     // { dg-warning "may alter its value" }
-  signed char k = (int) (unsigned short int) ss;       // { dg-warning "may alter its value" }
+  signed char i = (int) (unsigned short int) sc;       // { dg-warning "may change value" }
+  unsigned char j = (unsigned int) (short int) us;     // { dg-warning "may change value" }
+  signed char k = (int) (unsigned short int) ss;       // { dg-warning "may change value" }
 }
 
 void test2 (void)
index 83daaa06928c45465562036e6c720a3dc4445780..d1e0f4ad4edff173129545e96758217a49be5eb5 100644 (file)
@@ -7,7 +7,7 @@ class Test
 {
   void eval()
   {
-    foo(bar());  // { dg-warning "may alter its value" }
+    foo(bar());  // { dg-warning "may change value" }
   }
 
   unsigned int bar() const
index f6a0cccdffc8de6df0522041414bd0aa5e9517ae..3fa71226b4892d156ddaf5e5cccd6d04149bba62 100644 (file)
@@ -40,26 +40,26 @@ void h (int x)
   fuc ('A');
   uc = 'A';
 
-  uc = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = x ? SCHAR_MIN : 1U;  /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = x ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = x ? INT_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = 1U * -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = ui + INT_MIN; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = ui ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+  uc = x ? 1U : -1; /* { dg-warning "unsigned conversion" } */
+  uc = x ? SCHAR_MIN : 1U;  /* { dg-warning "unsigned conversion" } */
+  uc = x ? 1 : -1; /* { dg-warning "unsigned conversion" } */
+  uc = x ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion" } */
+  ui = x ? 1U : -1; /* { dg-warning "unsigned conversion" } */
+  ui = x ? INT_MIN : 1U; /* { dg-warning "unsigned conversion" } */
+  ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion" } */
+  ui = 1U * -1; /* { dg-warning "unsigned conversion" } */
+  ui = ui + INT_MIN; /* { dg-warning "unsigned conversion" } */
+  ui = x ? 1 : -1; /* { dg-warning "unsigned conversion" } */
+  ui = ui ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion" } */
 
-  fuc (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = -1;  /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  fui (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  fuc ('\xa0'); /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  fui ('\xa0');/* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+  fuc (-1); /* { dg-warning "unsigned conversion" } */
+  uc = -1;  /* { dg-warning "unsigned conversion" } */
+  fui (-1); /* { dg-warning "unsigned conversion" } */
+  ui = -1; /* { dg-warning "unsigned conversion" } */
+  fuc ('\xa0'); /* { dg-warning "unsigned conversion" } */
+  uc = '\xa0'; /* { dg-warning "unsigned conversion" } */
+  fui ('\xa0');/* { dg-warning "unsigned conversion" } */
+  ui = '\xa0'; /* { dg-warning "unsigned conversion" } */
   fsi (0x80000000); /* { dg-warning "conversion" } */
   si = 0x80000000;  /* { dg-warning "conversion" } */
 
@@ -91,5 +91,5 @@ void h (int x)
   ui = sc;  /* { dg-warning "conversion" } */
 }
 
-unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "unsigned conversion" } */
 
index 314e35182704ccb9a494d38bf6def458e478e83f..9177373a9391f0cae45d6f42b0bee6627184bc44 100644 (file)
@@ -102,14 +102,14 @@ void
 h2 (void)
 {
   fsc (SCHAR_MAX + 1);
-  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */
   fsc (UCHAR_MAX);
-  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */
   fuc (-1);
-  fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
   fuc (SCHAR_MIN);
-  fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
-  fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
+  fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
 }
 
 void fui (unsigned int);
index b319660f68fa333e3f420037f31b52598d43cd91..91afd01e09b6d3b5aab1eb1f296410d925de1e60 100644 (file)
@@ -100,15 +100,15 @@ void fsc (signed char);
 void
 h2 (void)
 {
-  fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (UCHAR_MAX); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */
+  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */
+  fsc (UCHAR_MAX); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */
+  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */
   fuc (-1);
-  fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
   fuc (SCHAR_MIN);
-  fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
-  fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
+  fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
 }
 
 void fui (unsigned int);
index dfe87411507cd59a5f639e0c6cd217197077a35d..3f0bf1f72403ecd6b514d7b1af918014bd3d801b 100644 (file)
@@ -103,15 +103,15 @@ void fsc (signed char);
 void
 h2 (void)
 {
-  fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (UCHAR_MAX); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in conversion" } */
+  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion" } */
+  fsc (UCHAR_MAX); /* { dg-warning "overflow in conversion" } */
+  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion" } */
   fuc (-1);
-  fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
   fuc (SCHAR_MIN);
-  fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
-  fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion" } */
+  fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion" } */
 }
 
 void fui (unsigned int);
index 19345c51162ed5f43b6a127477b4d266ed9e4873..628c0502a9c43ba346ab2e2d1a5ba36ca4a20caa 100644 (file)
@@ -63,7 +63,7 @@ void func3()
      warn.  */
   uchar_x = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion" } */
   uchar_x = bar != 0
-    ? (unsigned char) 1024 /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+    ? (unsigned char) 1024 /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes the value of .-1." } */
     : -1;
 }
 
index 35b1df0898ad8a9d3db4cb4dcc9e8c02686588f9..2f7a6dd438abf2cc5c2c15e5dd14093c35c72bed 100644 (file)
@@ -8,4 +8,4 @@ struct Type {
   void setBTK();
 };
 
-void Type::setBTK() { kind = DTK; } // { dg-warning "truncate" }
+void Type::setBTK() { kind = DTK; } // { dg-warning "conversion from '\[^\n\r]+' to .unsigned char:1. changes value from" }
index d45749d69c0670b2b09e8764e24a21ba694e173a..d102d169d02987126f8d12b45c4c79d238427a79 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -Wconversion" } */
 
-unsigned f(unsigned a) { return a + -1; }  /* { dg-warning "negative" } */
+unsigned f(unsigned a) { return a + -1; }  /* { dg-warning "conversion" } */
 
index be749a9a65f5b9951c814c317f09dd618b1457f8..e54fe1a8ace49d0c24523b7049f22812f72fb1be 100644 (file)
@@ -19,9 +19,9 @@ void test1 (void)
   unsigned char f = (int) uc;
   signed char g = (int) sc;
   unsigned char h = (unsigned int) (short int) uc;
-  signed char i = (int) (unsigned short int) sc;       /* { dg-warning "may alter its value" "" { target { int32plus } } } */
-  unsigned char j = (unsigned int) (short int) us;     /* { dg-warning "may alter its value" } */
-  signed char k = (int) (unsigned short int) ss;       /* { dg-warning "may alter its value" } */
+  signed char i = (int) (unsigned short int) sc;       /* { dg-warning "conversion from .int. to .signed char. may change value" "" { target { int32plus } } } */
+  unsigned char j = (unsigned int) (short int) us;     /* { dg-warning "may change value" } */
+  signed char k = (int) (unsigned short int) ss;       /* { dg-warning "may change value" } */
 }
 
 void test2 (void)
index 0e6c39022f495f1702ab546d85a11cd36c86dac1..bc7439de85b1214815fda0c55d686905d1b14d93 100644 (file)
@@ -63,10 +63,10 @@ var_complex_narrowing (void)
   double _Complex doublec = 0.;
 
   vdoublec = floatc;
-  vfloatc = doublec; /* { dg-warning "float-conversion" } */
+  vfloatc = doublec; /* { dg-warning "conversion from .complex double. to .complex float. may change value" } */
 
   fdoublec (floatc);
-  ffloatc (doublec); /* { dg-warning "float-conversion" } */
+  ffloatc (doublec); /* { dg-warning "conversion from .complex double. to .complex float. may change value" } */
 }
 
 /* Check implicit conversions of complex values to integers.  */
index 3839a39bce42c35009bb5bd1041ecfbf653081ec..80990cb66045c1bdf9818de650cdd607a51695ad 100644 (file)
@@ -32,11 +32,11 @@ var_float_to_int (void)
 {
   double _Complex doublec = 0.;
 
-  fsic (doublec); /* { dg-warning "float-conversion" } */
-  fuic (doublec); /* { dg-warning "float-conversion" } */
+  fsic (doublec); /* { dg-warning "conversion" } */
+  fuic (doublec); /* { dg-warning "conversion" } */
 
-  vsic = doublec; /* { dg-warning "float-conversion" } */
-  vuic = doublec; /* { dg-warning "float-conversion" } */
+  vsic = doublec; /* { dg-warning "conversion" } */
+  vuic = doublec; /* { dg-warning "conversion" } */
 }
 
 /* Check implicit conversions of integer complex-domain values to integer
@@ -75,9 +75,9 @@ const_float_to_int (void)
   vsic = 1. - 1.i;
   vuic = 1. + 1.i;
 
-  fsic (0.5 + 0.i); /* { dg-warning "float-conversion" } */
-  vsic = 0.5 + 0.i; /* { dg-warning "float-conversion" } */
-  fuic (0.5 + 0.i); /* { dg-warning "float-conversion" } */
+  fsic (0.5 + 0.i); /* { dg-warning "conversion" } */
+  vsic = 0.5 + 0.i; /* { dg-warning "conversion" } */
+  fuic (0.5 + 0.i); /* { dg-warning "conversion" } */
 }
 
 /* Check implicit conversions of integer complex-domain constants to integer
@@ -96,8 +96,8 @@ const_complex_int_to_real_int (void)
   fui (UINT_MAX + 1ull + 0i); /* { dg-warning "conversion" } */
   vui = UINT_MAX + 1ull + 0i; /* { dg-warning "conversion" } */
 
-  ffloat (UINT_MAX + 0i); /* { dg-warning "float-conversion" } */
-  vfloat = UINT_MAX + 0i; /* { dg-warning "float-conversion" } */
+  ffloat (UINT_MAX + 0i); /* { dg-warning "conversion" } */
+  vfloat = UINT_MAX + 0i; /* { dg-warning "conversion" } */
 }
 
 void
@@ -116,12 +116,12 @@ const_complex_int_narrowing (void)
   vuic = (UINT_MAX + 1ull) + 1i; /* { dg-warning "conversion" } */
   vuic = (UINT_MAX + 1ull) + (UINT_MAX + 1ull) * 1i; /* { dg-warning "conversion" } */
 
-  ffloatc (UINT_MAX * 1i); /* { dg-warning "float-conversion" } */
-  ffloatc (UINT_MAX + 1i); /* { dg-warning "float-conversion" } */
-  ffloatc (UINT_MAX + UINT_MAX * 1i); /* { dg-warning "float-conversion" } */
+  ffloatc (UINT_MAX * 1i); /* { dg-warning "conversion" } */
+  ffloatc (UINT_MAX + 1i); /* { dg-warning "conversion" } */
+  ffloatc (UINT_MAX + UINT_MAX * 1i); /* { dg-warning "conversion" } */
 
-  vfloatc = UINT_MAX * 1i; /* { dg-warning "float-conversion" } */
-  vfloatc = UINT_MAX + 1i; /* { dg-warning "float-conversion" } */
-  vfloatc = UINT_MAX + UINT_MAX * 1i; /* { dg-warning "float-conversion" } */
+  vfloatc = UINT_MAX * 1i; /* { dg-warning "conversion" } */
+  vfloatc = UINT_MAX + 1i; /* { dg-warning "conversion" } */
+  vfloatc = UINT_MAX + UINT_MAX * 1i; /* { dg-warning "conversion" } */
 }
 
index dc13e8fab36b14a48c8a88e94d6627219103a0e0..cf7745cf83752dbe48dcf19a100f349c769f5231 100644 (file)
@@ -40,28 +40,28 @@ void h (int x)
   fuc ('A');
   uc = 'A';
 
-  uc = x ? 1U : -1; /* { dg-warning " conversion" "conversion" } */
-  /* { dg-warning "negative integer implicitly converted to unsigned type" "implicit" { target *-*-* } .-1 } */
-  uc = x ? SCHAR_MIN : 1U; /* { dg-warning " conversion" "conversion" } */
-  /* { dg-warning "negative integer implicitly converted to unsigned type" "implicit" { target *-*-* } .-1 } */
-  uc = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = x ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = x ? INT_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = 1U * -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = ui + INT_MIN; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = ui ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+  uc = x ? 1U : -1; /* { dg-warning "conversion from .unsigned int. to .unsigned char." } */
+  /* { dg-warning "unsigned conversion" "implicit" { target *-*-* } .-1 } */
+  uc = x ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion" } */
+  /* { dg-warning "conversion from .unsigned int. to .unsigned char." "implicit" { target *-*-* } .-1 } */
+  uc = x ? 1 : -1; /* { dg-warning "signed conversion" } */
+  uc = x ? SCHAR_MIN : 1; /* { dg-warning "signed conversion" } */
+  ui = x ? 1U : -1; /* { dg-warning "signed conversion" } */
+  ui = x ? INT_MIN : 1U; /* { dg-warning "signed conversion" } */
+  ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "signed conversion" } */
+  ui = 1U * -1; /* { dg-warning "signed conversion" } */
+  ui = ui + INT_MIN; /* { dg-warning "signed conversion" } */
+  ui = x ? 1 : -1; /* { dg-warning "signed conversion" } */
+  ui = ui ? SCHAR_MIN : 1; /* { dg-warning "signed conversion" } */
 
-  fuc (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = -1;  /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  fui (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  fuc ('\xa0'); /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  fui ('\xa0');/* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+  fuc (-1); /* { dg-warning "signed conversion" } */
+  uc = -1;  /* { dg-warning "signed conversion" } */
+  fui (-1); /* { dg-warning "signed conversion" } */
+  ui = -1; /* { dg-warning "signed conversion" } */
+  fuc ('\xa0'); /* { dg-warning "signed conversion" } */
+  uc = '\xa0'; /* { dg-warning "signed conversion" } */
+  fui ('\xa0');/* { dg-warning "signed conversion" } */
+  ui = '\xa0'; /* { dg-warning "signed conversion" } */
   fsi (0x80000000); /* { dg-warning "conversion" } */
   si = 0x80000000;  /* { dg-warning "conversion" } */
 
@@ -93,6 +93,6 @@ void h (int x)
   ui = sc;  /* { dg-warning "conversion" } */
 }
 
-unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "signed conversion" } */
 
 
index 0300850f904a3f5f4f3edf7779712a4630c8b41d..bda61eb8bbf8d97973a549c5d81e201bc6fdff5b 100644 (file)
@@ -40,28 +40,28 @@ void h (int x)
   fuc ('A');
   uc = 'A';
 
-  uc = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = x ? SCHAR_MIN : 1U;  /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = x ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = x ? 1U : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = x ? INT_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = 1U * -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = ui + INT_MIN; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = x ? 1 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = ui ? SCHAR_MIN : 1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+  uc = x ? 1U : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-1. to .\[0-9\]+." } */
+  uc = x ? SCHAR_MIN : 1U;  /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-\[0-9\]+. to .\[0-9\]+." } */
+  uc = x ? 1 : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes the value of .-1." } */
+  uc = x ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes the value of .-\[0-9\]+." } */
+  ui = x ? 1U : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-1. to .\[0-9\]+." } */
+  ui = x ? INT_MIN : 1U; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-\[0-9\]+. to .\[0-9\]+." } */
+  ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */
+  ui = 1U * -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */
+  ui = ui + INT_MIN; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */
+  ui = x ? 1 : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes the value of .-1." } */
+  ui = ui ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes the value of " } */
 
-  fuc (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = -1;  /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  fui (-1); /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  fuc ('\xa0'); /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  uc = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  fui ('\xa0');/* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  ui = '\xa0'; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
-  fsi (0x80000000); /* { dg-warning "conversion" } */
-  si = 0x80000000;  /* { dg-warning "conversion" } */
+  fuc (-1); /* { dg-warning "unsigned conversion" } */
+  uc = -1;  /* { dg-warning "unsigned conversion" } */
+  fui (-1); /* { dg-warning "unsigned conversion" } */
+  ui = -1; /* { dg-warning "unsigned conversion" } */
+  fuc ('\xa0'); /* { dg-warning "unsigned conversion" } */
+  uc = '\xa0'; /* { dg-warning "unsigned conversion" } */
+  fui ('\xa0');/* { dg-warning "unsigned conversion" } */
+  ui = '\xa0'; /* { dg-warning "unsigned conversion" } */
+  fsi (0x80000000); /* { dg-warning "signed conversion" } */
+  si = 0x80000000;  /* { dg-warning "signed conversion" } */
 
 
   fsi (UINT_MAX - 1);  /* { dg-warning "conversion" } */
@@ -85,12 +85,12 @@ void h (int x)
   uc = sc;  /* { dg-warning "conversion" } */
   fsi (ui); /* { dg-warning "conversion" } */
   si = ui;  /* { dg-warning "conversion" } */
-  fui (si); /* { dg-warning "conversion" } */ 
-  ui = si;  /* { dg-warning "conversion" } */ 
+  fui (si); /* { dg-warning "conversion" } */
+  ui = si;  /* { dg-warning "conversion" } */
   fui (sc); /* { dg-warning "conversion" } */
   ui = sc;  /* { dg-warning "conversion" } */
 }
 
-unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+unsigned fui (unsigned a) { return a + -1; } /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value" } */
 
 
index e3f5f1bcc35bf222cebec8c36cd97475a08d2b39..92cf2f6cc24394a6942965e8db4aaf92382ca846 100644 (file)
@@ -11,13 +11,13 @@ struct bf
   int b: 2;
 };
 
-struct bf p = {4, 0};          /* { dg-warning "truncated" } */
-struct bf q = {0, 2};          /* { dg-warning "overflow" } */
-struct bf r = {3, -2};         /* { dg-bogus "(truncated|overflow)" } */
+struct bf p = {4, 0};          /* { dg-warning "unsigned conversion from .int. to 'unsigned char:2' changes value from .4. to .0." } */
+struct bf q = {0, 2};          /* { dg-warning "overflow in conversion from .int. to .signed char:2. changes value from .2. to .-2." } */
+struct bf r = {3, -2};         /* { dg-bogus "(trunc|overflow)" } */
 
 void foo ()
 {
-  p.a = 4, p.b = 0;            /* { dg-warning "truncated" } */
-  q.a = 0, q.b = 2;            /* { dg-warning "overflow" } */
-  r.a = 3, r.b = -2;           /* { dg-bogus "(truncated|overflow)" } */
+  p.a = 4, p.b = 0;            /* { dg-warning "unsigned conversion from .int. to .unsigned char:2. changes value from .4. to .0." } */
+  q.a = 0, q.b = 2;            /* { dg-warning "overflow in conversion from .int. to .signed char:2. changes value from .2. to .-2." } */
+  r.a = 3, r.b = -2;           /* { dg-bogus "(trunc|overflow)" } */
 }
index 5cd704a8d7335228df5999ec97a845939b3a65dd..e4f2aff78743864d914e9e0b3fa826c794c9b0c2 100644 (file)
@@ -20,7 +20,7 @@ f (void)
   /* Overflow.  */
   struct t b = { INT_MAX + 1 }; /* { dg-warning "integer overflow in expression" } */
   /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
-  struct t c = { DBL_MAX }; /* { dg-warning "overflow in implicit constant conversion" } */
+  struct t c = { DBL_MAX }; /* { dg-warning "overflow in conversion from .double. to .int. chages value " } */
   /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
   /* Bad operator outside sizeof.  */
   struct s d = { 1 ? 1.0 : atan (a.d) }; /* { dg-error "is not a constant expression|near initialization" } */
index 56a147864eb4090cb50995ee0a1aa188aefc4e64..f423b005e20a84c5389b07fddb5d463e7ce3366c 100644 (file)
@@ -6,10 +6,10 @@
 
 #include <float.h>
 
-int a = DBL_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
+int a = DBL_MAX; /* { dg-warning "overflow in conversion" } */
 /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
 int b = (int) DBL_MAX; /* { dg-error "overflow" } */
-unsigned int c = -1.0; /* { dg-warning "overflow in implicit constant conversion" } */
+unsigned int c = -1.0; /* { dg-warning "overflow in conversion" } */
 /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
 unsigned int d = (unsigned)-1.0; /* { dg-error "overflow" } */
 
@@ -31,5 +31,5 @@ int h1 = (0 ? 0 >> -1: 0);
 
 int i = -1 << 0;
 
-int j[1] = { DBL_MAX }; /* { dg-warning "overflow in implicit constant conversion" } */
+int j[1] = { DBL_MAX }; /* { dg-warning "overflow in conversion" } */
 /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
index c663723c03a501a2d91b10b41b358e4692f1ad94..bf23a4a4173b103646603059466d1a7f83c10229 100644 (file)
@@ -7,10 +7,10 @@
 #include <float.h>
 #include <limits.h>
 
-int a = DBL_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
+int a = DBL_MAX; /* { dg-warning "overflow in conversion" } */
 /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
 int b = (int) DBL_MAX; /* { dg-error "overflow" } */
-unsigned int c = -1.0; /* { dg-warning "overflow in implicit constant conversion" } */
+unsigned int c = -1.0; /* { dg-warning "overflow in conversion" } */
 /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
 unsigned int d = (unsigned)-1.0; /* { dg-error "overflow" } */
 
@@ -33,7 +33,7 @@ int h1 = (0 ? 0 >> -1: 0);
 int i = -1 << 0;
 /* { dg-error "constant" "constant" { target *-*-* } .-1 } */
 
-int j[1] = { DBL_MAX }; /* { dg-warning "overflow in implicit constant conversion" } */
+int j[1] = { DBL_MAX }; /* { dg-warning "overflow in conversion" } */
 /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
 
 int array[2] = { [0 * (INT_MAX + 1)] = 0 }; /* { dg-warning "integer overflow in expression" } */
index 48185e900518a94859874c6bd5333fd4da82e445..8eb322579cfbdd8559f20a8159f94052a01a0ed1 100644 (file)
@@ -85,14 +85,14 @@ void
 h2 (void)
 {
   fsc (SCHAR_MAX + 1);
-  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value " } */
   fsc (UCHAR_MAX);
-  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value from " } */
   fuc (-1);
-  fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */
   fuc (SCHAR_MIN);
-  fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
-  fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */
+  fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */
 }
 
 void fui (unsigned int);
index f77c20f9559a2827571fe861f06f361b304525bd..f048d6dae2a45e51b7fae8dc4ae1d1d999cfe4e9 100644 (file)
@@ -86,21 +86,21 @@ h2 (void)
 {
   fsc (SCHAR_MAX + 1);
   /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */
-  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */
   /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */
   fsc (UCHAR_MAX);
   /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */
-  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from 'int' to 'signed char' changes value " } */
   /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */
   fuc (-1);
   /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */
-  fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */
   /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */
   fuc (SCHAR_MIN);
   /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */
-  fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value " } */
   /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */
-  fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
   /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } .-1 } */
 }
 
index 8bd190e12964a9ee0331f26ef29ca8610202dedf..664011e401df68316a6f952469438718d2eeda68 100644 (file)
@@ -91,15 +91,15 @@ void fsc (signed char);
 void
 h2 (void)
 {
-  fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (UCHAR_MAX); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */
+  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */
+  fsc (UCHAR_MAX); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */
+  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value " } */
   fuc (-1);
-  fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
   fuc (SCHAR_MIN);
-  fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
-  fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
+  fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
 }
 
 void fui (unsigned int);
index a28cb56b30fa39bb938f8c82346162bbfb1aaa67..52677ce897a6f1db506191d8058b44c128f9a69c 100644 (file)
@@ -21,7 +21,7 @@ enum e {
   E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */
   /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
   /* Again, overflow in evaluated subexpression.  */
-  E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */
+  E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression of type .int. results in .-\[0-9\]+." } */
   /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
   /* A cast does not constitute overflow in conversion.  */
   E7 = (char) INT_MAX
@@ -91,15 +91,15 @@ void fsc (signed char);
 void
 h2 (void)
 {
-  fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (UCHAR_MAX); /* { dg-warning "overflow in implicit constant conversion" } */
-  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in conversion from .int. to .signed char. changes value" } */
+  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in conversion" } */
+  fsc (UCHAR_MAX); /* { dg-warning "overflow in conversion" } */
+  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in conversion" } */
   fuc (-1);
-  fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (UCHAR_MAX + 1); /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value" } */
   fuc (SCHAR_MIN);
-  fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
-  fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (SCHAR_MIN - 1); /* { dg-warning "unsigned conversion" } */
+  fuc (-UCHAR_MAX); /* { dg-warning "unsigned conversion" } */
 }
 
 void fui (unsigned int);
index 472d4a7cab14185384cebeb819a6d104093f21fc..b2c8dc31d9571ab017b00c167696d217634c8347 100644 (file)
@@ -3,5 +3,5 @@
 /* { dg-options "-Woverflow" } */
 
 unsigned char rx_async(unsigned char p) {
-    return p & 512; /* { dg-warning "overflow in implicit constant conversion" } */
+    return p & 512; /* { dg-warning "overflow in conversion from .int. to .unsigned char. chages value" } */
 }
index 43ecda0a56e83e67d492f4dab9b9b22c25ef0ef8..ace605517dc2cb919c90f76b408126c09ded3440 100644 (file)
@@ -7,7 +7,7 @@ void foo (int j)
   int i3 = 1 + INT_MAX; /* { dg-warning "integer overflow" } */
   int i4 = +1 + INT_MAX; /* { dg-warning "integer overflow" } */
   int i5 = (int)((double)1.0 + INT_MAX);
-  int i6 = (double)1.0 + INT_MAX; /* { dg-warning "overflow in implicit constant" } */
+  int i6 = (double)1.0 + INT_MAX; /* { dg-warning "overflow in conversion from .double. to .int. chages value" } */
   int i7 = 0 ? (int)(double)1.0 + INT_MAX : 1;
   int i8 = 1 ? 1 : (int)(double)1.0 + INT_MAX;
   int i9 = j ? (int)(double)1.0 + INT_MAX : 1; /* { dg-warning "integer overflow" } */
diff --git a/gcc/testsuite/gcc.dg/overflow-warn-9.c b/gcc/testsuite/gcc.dg/overflow-warn-9.c
new file mode 100644 (file)
index 0000000..88d6afb
--- /dev/null
@@ -0,0 +1,64 @@
+/* PR c/80731 - poor -Woverflow warnings, missing detail
+   { dg-do compile }
+   { dg-options "-Wconversion -Woverflow -Wno-override-init -std=c99" }
+   { dg-require-effective-target int32plus } */
+
+#include <limits.h>
+
+struct Types
+{
+  signed char sc;
+  unsigned char uc;
+  signed short ss;
+  unsigned short us;
+  signed int si;
+  unsigned int ui;
+  signed long sl;
+  unsigned long ul;
+  signed long long sll;
+  unsigned long long ull;
+};
+
+const struct Types t1 = {
+  /* According to 6.3.1.3 of C11:
+     -2-  Otherwise, if the new type is unsigned, the value is converted
+         by repeatedly adding or subtracting one more than the maximum
+         value that can be represented in the new type until the value
+         is in the range of the new type.
+
+     These conversions are diagnosed by -Wsign-conversion and -Wconversion,
+     respectively, by mentioning "unsigned conversion" if the conversion
+     results in sign change, and just "conversion" otherwise, as follows:  */
+
+  .uc = SCHAR_MIN,          /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value from .-128. to .128." } */
+  .uc = -1,                 /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes value from .-1. to .255." } */
+
+  .uc = UCHAR_MAX + 1,      /* { dg-warning "conversion from 'int' to 'unsigned char' changes value from .256. to .0." } */
+  .uc = UCHAR_MAX * 2,      /* { dg-warning "conversion from 'int' to 'unsigned char' changes value from .510. to .254." } */
+
+  /* According to 6.3.1.3 of C11:
+     -3-  Otherwise, the new type is signed and the value cannot be
+         represented in it; either the result is implementation-defined
+         or an implementation-defined signal is raised.
+
+     In GCC such conversions wrap and are diagnosed by mentioning "overflow"
+     if the absolute value of the operand is in excess of the maximum of
+     the destination of type, and "conversion" otherwise, as follows:  */
+
+  .sc = SCHAR_MAX + 1,      /* { dg-warning "conversion from .int. to .signed char. changes value from .128. to .-128." } */
+  .sc = SCHAR_MAX + 2,      /* { dg-warning "conversion from .int. to .signed char. changes value from .129. to .-127." } */
+  .sc = SCHAR_MAX * 2,      /* { dg-warning "conversion from .int. to .signed char. changes value from .254. to .-2." } */
+  .sc = SCHAR_MAX * 2 + 3,  /* { dg-warning "conversion from .int. to .signed char. changes value from .257. to .1." } */
+  .sc = SCHAR_MAX * 3 + 3,  /* { dg-warning "conversion from .int. to .signed char. changes value from .384. to .-128." } */
+
+
+  .ss = SHRT_MAX + 1,       /* { dg-warning "conversion from 'int' to 'short int' changes value from .32768. to .-32768." } */
+  .us = USHRT_MAX + 1,      /* { dg-warning "unsigned conversion from .int. to .short unsigned int. changes value from .65536. to .0." } */
+
+  .si = INT_MAX + 1LU,      /* { dg-warning "signed conversion from 'long unsigned int. to 'int' changes value from .2147483648. to .-2147483648." } */
+  .ui = UINT_MAX + 1L,      /* { dg-warning "signed conversion from .long int. to .unsigned int. changes value from .4294967296. to .0." } */
+  .ui = UINT_MAX + 1LU,     /* { dg-warning "conversion from .long unsigned int. to .unsigned int. changes value from .4294967296. to .0." } */
+
+  .sl = LONG_MAX + 1LU,     /* { dg-warning "signed conversion from .long unsigned int. to .long int. changes value from .9223372036854775808. to .-9223372036854775808." } */
+  .ul = ULONG_MAX + 1LU     /* there should be some warning here */
+};
index 86612d5283f0c88fd6d77519a8c3d82a2c139b95..b52354f80a6cad9cfea24a8c849a408547ed7c5e 100644 (file)
@@ -32,7 +32,7 @@ void func1()
   /* At least one branch of ? does not fit in the destination, thus
      warn.  */
   unsigned_bit.x = bar != 0 ? 2 : 0; /* { dg-warning "conversion" } */
-  unsigned_bit.x = bar != 0 ? 0 : -1; /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+  unsigned_bit.x = bar != 0 ? 0 : -1; /* { dg-warning "-Wsign-conversion" } */
 }
 
 void func2()
@@ -62,7 +62,7 @@ void func3()
   /* At least one branch of ? does not fit in the destination, thus
      warn.  */
   uchar_x = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion" } */
-  uchar_x = bar != 0  /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+  uchar_x = bar != 0  /* { dg-warning "-Wsign-conversion" } */
     ? (unsigned char) 1024 
     : -1;
 }
index 6dba8c713fcfefa1e9f061762b69314bde2f4a0d..cec8d07edd5a8590c99a5dcee319ad47f93965e2 100644 (file)
@@ -9,13 +9,13 @@ int
 g (void)
 {
   sitype si = 12;
-  unsigned int ui = -1; /* { dg-warning "21:negative integer implicitly converted to unsigned type" } */
+  unsigned int ui = -1; /* { dg-warning "21:-Wsign-conversion" } */
   unsigned char uc;
   ui = si; /* { dg-warning "8:conversion" } */
-  si = 0x80000000; /* { dg-warning "8:conversion of unsigned constant value to negative integer" } */
+  si = 0x80000000; /* { dg-warning "8:-Wsign-conversion" } */
   si = 3.2f; /* { dg-warning "8:conversion" } */
-  uc = 256; /* { dg-warning "8:large integer implicitly truncated to unsigned type" } */
-  si = 0x800000000; /* { dg-warning "8:overflow in implicit constant conversion" } */
+  uc = 256; /* { dg-warning "8:-Woverflow" } */
+  si = 0x800000000; /* { dg-warning "8:-Woverflow" } */
   return f (si) /* { dg-warning "13:conversion" } */
          + f (si); /* { dg-warning "15:conversion" } */
 }
index 8eb1a796bbc8b20a30a50d63ebcdfb2b8808d6f0..1c79397317e0812d53ca187a56d9c5642e0e6fbf 100644 (file)
@@ -1,7 +1,6 @@
 /* PR c/59963 */
 /* { dg-do compile } */
 /* { dg-options "-Woverflow -Wconversion" } */
-/* { dg-require-effective-target int32plus } */
 
 extern void bar (unsigned char);
 extern void bar8 (unsigned char, unsigned char, unsigned char, unsigned char,
@@ -13,25 +12,25 @@ extern int f (short a, short b);
 int
 g (void)
 {
-  return f (0xffffffffL, /* { dg-warning "13:overflow in implicit constant conversion" } */
-            0xffffffffL) /* { dg-warning "13:overflow in implicit constant conversion" } */
-        && f (0xffffffffL, /* { dg-warning "9:overflow in implicit constant conversion" } */
-              0xffffffffL); /* { dg-warning "9:overflow in implicit constant conversion" } */
+  return f (0xffffffffL, /* { dg-warning "13:-Woverflow" } */
+           0xffffffffL) /* { dg-warning "13:-Woverflow" } */
+        && f (0xffffffffL, /* { dg-warning "9:-Woverflow" } */
+              0xffffffffL); /* { dg-warning "9:-Woverflow" } */
 }
 
 void
 foo (int i)
 {
-  bar (256); /* { dg-warning "8:large integer implicitly truncated to unsigned type" } */
+  bar (256); /* { dg-warning "8:-Woverflow" } */
   bar (6.66f); /* { dg-warning "8:conversion" } */
-  bar8 (-1, /* { dg-warning "9:negative integer implicitly converted to unsigned type" } */
-        -2, /* { dg-warning "3:negative integer implicitly converted to unsigned type" } */
-         -3, /* { dg-warning "4:negative integer implicitly converted to unsigned type" } */
-          -4, /* { dg-warning "5:negative integer implicitly converted to unsigned type" } */
-           -5, /* { dg-warning "6:negative integer implicitly converted to unsigned type" } */
-            -6, /* { dg-warning "7:negative integer implicitly converted to unsigned type" } */
-             -7, /* { dg-warning "8:negative integer implicitly converted to unsigned type" } */
-              -8); /* { dg-warning "9:negative integer implicitly converted to unsigned type" } */
+  bar8 (-1, /* { dg-warning "9:-Wsign-conversion" } */
+        -2, /* { dg-warning "3:-Wsign-conversion" } */
+         -3, /* { dg-warning "4:-Wsign-conversion" } */
+          -4, /* { dg-warning "5:-Wsign-conversion" } */
+           -5, /* { dg-warning "6:-Wsign-conversion" } */
+            -6, /* { dg-warning "7:-Wsign-conversion" } */
+             -7, /* { dg-warning "8:-Wsign-conversion" } */
+              -8); /* { dg-warning "9:-Wsign-conversion" } */
   bazu (i, i); /* { dg-warning "9:conversion" } */
-  bazi (0x8, 0x80000000); /* { dg-warning "14:conversion of unsigned constant value to negative integer" "" { xfail int16 } } */
+  bazi (0x8, 0x80000000); /* { dg-warning "14:-Wsign-conversion" "" { xfail int16 } } */
 }
index a2db9c9480c8fa3cb473adc14b1525890c67f0a9..0ddbe58a277f3f1a73ca3cca6d57ad7d19a596b5 100644 (file)
@@ -5,28 +5,28 @@
 
 struct S { int n, u[2]; };
 const signed char z[] = {
-  [0] = 0x100, /* { dg-warning "9:overflow in implicit constant conversion" } */
-  [2] = 0x101, /* { dg-warning "9:overflow in implicit constant conversion" } */
+  [0] = 0x100, /* { dg-warning "9:-Woverflow" } */
+  [2] = 0x101, /* { dg-warning "9:-Woverflow" } */
 };
 int A[] = {
-            0, 0x80000000, /* { dg-warning "16:conversion of unsigned constant value to negative integer" } */
-            0xA, 0x80000000, /* { dg-warning "18:conversion of unsigned constant value to negative integer" } */
-            0xA, 0xA, 0x80000000 /* { dg-warning "23:conversion of unsigned constant value to negative integer" } */
+           0, 0x80000000, /* { dg-warning "16:-Wsign-conversion" } */
+           0xA, 0x80000000, /* { dg-warning "18:-Wsign-conversion" } */
+           0xA, 0xA, 0x80000000 /* { dg-warning "23:-Wsign-conversion" } */
           };
-int *p = (int []) { 0x80000000 }; /* { dg-warning "21:conversion of unsigned constant value to negative integer" } */
-union { int k; } u = { .k = 0x80000000 }; /* { dg-warning "29:conversion of unsigned constant value to negative integer" } */
+int *p = (int []) { 0x80000000 }; /* { dg-warning "21:-Wsign-conversion" } */
+union { int k; } u = { .k = 0x80000000 }; /* { dg-warning "29:-Wsign-conversion" } */
 typedef int H[];
 void
 foo (void)
 {
-  signed char a[][3] = { { 0x100, /* { dg-warning "28:overflow in implicit constant conversion" } */
-                    1, 0x100 }, /* { dg-warning "24:overflow in implicit constant conversion" } */
-                  { '\0', 0x100, '\0' } /* { dg-warning "27:overflow in implicit constant conversion" } */
+  signed char a[][3] = { { 0x100, /* { dg-warning "28:-Woverflow" } */
+                   1, 0x100 }, /* { dg-warning "24:-Woverflow" } */
+                 { '\0', 0x100, '\0' } /* { dg-warning "27:-Woverflow" } */
                 };
-  (const signed char []) { 0x100 }; /* { dg-warning "28:overflow in implicit constant conversion" } */
+  (const signed char []) { 0x100 }; /* { dg-warning "28:-Woverflow" } */
   (const float []) { 1e0, 1e1, 1e100 }; /* { dg-warning "32:conversion" } */
-  struct S s1 = { 0x80000000 }; /* { dg-warning "19:conversion of unsigned constant value to negative integer" } */
-  struct S s2 = { .n = 0x80000000 }; /* { dg-warning "24:conversion of unsigned constant value to negative integer" } */
-  struct S s3 = { .u[1] = 0x80000000 }; /* { dg-warning "27:conversion of unsigned constant value to negative integer" } */
-  H h = { 1, 2, 0x80000000 }; /* { dg-warning "17:conversion of unsigned constant value to negative integer" } */
+  struct S s1 = { 0x80000000 }; /* { dg-warning "19:-Wsign-conversion" } */
+  struct S s2 = { .n = 0x80000000 }; /* { dg-warning "24:-Wsign-conversion" } */
+  struct S s3 = { .u[1] = 0x80000000 }; /* { dg-warning "27:-Wsign-conversion" } */
+  H h = { 1, 2, 0x80000000 }; /* { dg-warning "17:-Wsign-conversion" } */
 }
index 7778b66e087c4030ecd897dbd41c1301811b9502..76fd982b5757641ec0623c8901a33aaed7721294 100644 (file)
@@ -10,7 +10,7 @@ foo (unsigned int i)
 {
   switch (i)
   {
-    case 123456123456ULL: /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+    case 123456123456ULL: /* { dg-warning "conversion from .long long unsigned int. to .unsigned int. changes value" } */
       return 0;
     default:
       return 3;
index d6f18eeade72d5595d01387e5b8cb7176dd15203..d9927824e3c753086a0db080f9d7a392f98877e9 100644 (file)
@@ -25,9 +25,9 @@ extern void full (unsigned long long);
 
 void m (char16_t c0, char32_t c1)
 {
-    f_c (c0);  /* { dg-warning "alter its value" } */
-    fsc (c0);  /* { dg-warning "alter its value" } */
-    fuc (c0);  /* { dg-warning "alter its value" } */
+    f_c (c0);  /* { dg-warning "conversion from .char16_t\[^\n\r\]*. to .char. may change value" } */
+    fsc (c0);  /* { dg-warning "may change value" } */
+    fuc (c0);  /* { dg-warning "may change value" } */
     f_s (c0);  /* { dg-warning "change the sign" } */
     fss (c0);  /* { dg-warning "change the sign" } */
     fus (c0);
@@ -41,12 +41,12 @@ void m (char16_t c0, char32_t c1)
     fsll (c0);
     full (c0);
 
-    f_c (c1);  /* { dg-warning "alter its value" } */
-    fsc (c1);  /* { dg-warning "alter its value" } */
-    fuc (c1);  /* { dg-warning "alter its value" } */
-    f_s (c1);  /* { dg-warning "alter its value" } */
-    fss (c1);  /* { dg-warning "alter its value" } */
-    fus (c1);  /* { dg-warning "alter its value" } */
+    f_c (c1);  /* { dg-warning "may change value" } */
+    fsc (c1);  /* { dg-warning "may change value" } */
+    fuc (c1);  /* { dg-warning "may change value" } */
+    f_s (c1);  /* { dg-warning "may change value" } */
+    fss (c1);  /* { dg-warning "may change value" } */
+    fus (c1);  /* { dg-warning "may change value" } */
     f_i (c1);  /* { dg-warning "change the sign" "" { target { ! int16 } } } */
     fsi (c1);  /* { dg-warning "change the sign" "" { target { ! int16 } } } */
     fui (c1);
index 6ef4ae3ff7efbab0feb36deb0d80b8ca5755c507..f9ebd61845a15fc657a2f906d3f684768993df44 100644 (file)
@@ -12,10 +12,10 @@ char16_t    c2 = u'\U00064321';     /* { dg-warning "constant too long" } */
 char16_t       c3 = 'a';
 char16_t       c4 = U'a';
 char16_t       c5 = U'\u2029';
-char16_t       c6 = U'\U00064321';     /* { dg-warning "implicitly truncated" } */
+char16_t       c6 = U'\U00064321';     /* { dg-warning "conversion from .unsigned int. to .char16_t {aka short unsigned int}. changes value from .410401. to .17185." } */
 char16_t       c7 = L'a';
 char16_t       c8 = L'\u2029';
-char16_t       c9 = L'\U00064321';     /* { dg-warning "implicitly truncated" "" { target { 4byte_wchar_t } } } */
+char16_t       c9 = L'\U00064321';     /* { dg-warning "conversion" "" { target { 4byte_wchar_t } } } */
                                        /* { dg-warning "constant too long" "" { target { ! 4byte_wchar_t } } .-1 } */
 
 int main () {}