(digest_init): Don't call default_conversion before convert_for_assignment.
authorRichard Stallman <rms@gnu.org>
Tue, 13 Apr 1993 20:29:47 +0000 (20:29 +0000)
committerRichard Stallman <rms@gnu.org>
Tue, 13 Apr 1993 20:29:47 +0000 (20:29 +0000)
(parser_build_binary_op): Make NOP_EXPR, not NON_LVALUE_EXPR.

From-SVN: r4129

gcc/c-typeck.c

index d7745e3abf0b420fd765446d71ac4145c333a083..f809b358ae976d345b0d76e1070d6f0d3f5785be 100644 (file)
@@ -2218,7 +2218,10 @@ parser_build_binary_op (code, arg1, arg2)
   else
     {
       int flag = TREE_CONSTANT (result);
-      result = build1 (NON_LVALUE_EXPR, TREE_TYPE (result), result);
+      /* We use NOP_EXPR rather than NON_LVALUE_EXPR
+        so that convert_for_assignment won't strip it.
+        That way, we get warnings for things like p = (1 - 1).  */
+      result = build1 (NOP_EXPR, TREE_TYPE (result), result);
       C_SET_EXP_ORIGINAL_CODE (result, code);
       TREE_CONSTANT (result) = flag;
     }
@@ -5011,11 +5014,13 @@ digest_init (type, init, tail, require_constant, constructor_constant, ofwhat)
        ({
          if (ofwhat)
            push_string (ofwhat);
+         if (!raw_constructor)
+           inside_init = init;
+         /* Note that convert_for_assignment calls default_conversion
+            for arrays and functions.  We must not call it in the
+            case where inside_init is a null pointer constant.  */
          inside_init
-           = convert_for_assignment (type,
-                                     default_conversion (raw_constructor
-                                                         ? inside_init
-                                                         : init),
+           = convert_for_assignment (type, inside_init, 
                                      &initialization_message,
                                      NULL_TREE, NULL_TREE, 0);
        });