OSDN Git Service

Fix PR c++/43800
[pf3gnuchains/gcc-fork.git] / gcc / cp / typeck.c
index c601539..bc699a1 100644 (file)
@@ -61,7 +61,6 @@ static void casts_away_constness_r (tree *, tree *);
 static bool casts_away_constness (tree, tree);
 static void maybe_warn_about_returning_address_of_local (tree);
 static tree lookup_destructor (tree, tree, tree);
-static void warn_args_num (location_t, tree, bool);
 static int convert_arguments (tree, VEC(tree,gc) **, tree, int,
                               tsubst_flags_t);
 
@@ -1631,8 +1630,6 @@ cxx_sizeof_expr (tree e, tsubst_flags_t complain)
       && DECL_TEMPLATE_INSTANTIATION (e))
     instantiate_decl (e, /*defer_ok*/true, /*expl_inst_mem*/false);
 
-  e = mark_type_use (e);
-
   if (TREE_CODE (e) == COMPONENT_REF
       && TREE_CODE (TREE_OPERAND (e, 1)) == FIELD_DECL
       && DECL_C_BIT_FIELD (TREE_OPERAND (e, 1)))
@@ -1688,8 +1685,6 @@ cxx_alignof_expr (tree e, tsubst_flags_t complain)
       return e;
     }
 
-  e = mark_type_use (e);
-
   if (TREE_CODE (e) == VAR_DECL)
     t = size_int (DECL_ALIGN_UNIT (e));
   else if (TREE_CODE (e) == COMPONENT_REF
@@ -1839,9 +1834,7 @@ unlowered_expr_type (const_tree exp)
    in an rvalue context: the lvalue-to-rvalue, array-to-pointer, and
    function-to-pointer conversions.  In addition, manifest constants
    are replaced by their values, and bitfield references are converted
-   to their declared types. Note that this function does not perform the
-   lvalue-to-rvalue conversion for class types. If you need that conversion
-   to for class types, then you probably need to use force_rvalue.
+   to their declared types.
 
    Although the returned value is being used as an rvalue, this
    function does not wrap the returned expression in a
@@ -1858,8 +1851,6 @@ decay_conversion (tree exp)
   if (type == error_mark_node)
     return error_mark_node;
 
-  exp = mark_rvalue_use (exp);
-
   exp = resolve_nondeduced_context (exp);
   if (type_unknown_p (exp))
     {
@@ -1984,8 +1975,6 @@ perform_integral_promotions (tree expr)
   tree type;
   tree promoted_type;
 
-  expr = mark_rvalue_use (expr);
-
   /* [conv.prom]
 
      If the bitfield has an enumerated type, it is treated as any
@@ -3297,44 +3286,6 @@ cp_build_function_call_vec (tree function, VEC(tree,gc) **params,
   return ret;
 }
 \f
-/* Subroutine of convert_arguments.
-   Warn about wrong number of args are genereted. */
-
-static void
-warn_args_num (location_t loc, tree fndecl, bool too_many_p)
-{
-  if (fndecl)
-    {
-      if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
-       {
-         if (DECL_NAME (fndecl) == NULL_TREE
-             || IDENTIFIER_HAS_TYPE_VALUE (DECL_NAME (fndecl)))
-           error_at (loc,
-                     too_many_p
-                     ? G_("too many arguments to constructor %q#D")
-                     : G_("too few arguments to constructor %q#D"),
-                     fndecl);
-         else
-           error_at (loc,
-                     too_many_p
-                     ? G_("too many arguments to member function %q#D")
-                     : G_("too few arguments to member function %q#D"),
-                     fndecl);
-       }
-      else
-       error_at (loc,
-                 too_many_p
-                 ? G_("too many arguments to function %q#D")
-                 : G_("too few arguments to function %q#D"),
-                 fndecl);
-      inform (DECL_SOURCE_LOCATION (fndecl),
-             "declared here");
-    }
-  else
-    error_at (loc, too_many_p ? G_("too many arguments to function")
-                             : G_("too few arguments to function"));
-}
-
 /* Convert the actual parameter expressions in the list VALUES to the
    types in the list TYPELIST.  The converted expressions are stored
    back in the VALUES vector.
@@ -3356,11 +3307,26 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl,
                   int flags, tsubst_flags_t complain)
 {
   tree typetail;
+  const char *called_thing = 0;
   unsigned int i;
 
   /* Argument passing is always copy-initialization.  */
   flags |= LOOKUP_ONLYCONVERTING;
 
+  if (fndecl)
+    {
+      if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
+       {
+         if (DECL_NAME (fndecl) == NULL_TREE
+             || IDENTIFIER_HAS_TYPE_VALUE (DECL_NAME (fndecl)))
+           called_thing = "constructor";
+         else
+           called_thing = "member function";
+       }
+      else
+       called_thing = "function";
+    }
+
   for (i = 0, typetail = typelist;
        i < VEC_length (tree, *values);
        i++)
@@ -3375,7 +3341,15 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl,
        {
           if (complain & tf_error)
             {
-             warn_args_num (input_location, fndecl, /*too_many_p=*/true);
+              if (fndecl)
+                {
+                  error_at (input_location, "too many arguments to %s %q#D", 
+                           called_thing, fndecl);
+                 inform (DECL_SOURCE_LOCATION (fndecl),
+                         "declared here");
+                }
+              else
+                error ("too many arguments to function");
               return i;
             }
           else
@@ -3480,7 +3454,17 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl,
       else
        {
           if (complain & tf_error)
-           warn_args_num (input_location, fndecl, /*too_many_p=*/false);
+            {
+              if (fndecl)
+                {
+                  error_at (input_location, "too few arguments to %s %q#D", 
+                           called_thing, fndecl);
+                 inform (DECL_SOURCE_LOCATION (fndecl),
+                         "declared here");
+                }
+              else
+                error ("too few arguments to function");
+            }
          return -1;
        }
     }
@@ -4184,10 +4168,8 @@ cp_build_binary_op (location_t location,
        }
 
       build_type = boolean_type_node;
-      if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
-          || code0 == ENUMERAL_TYPE)
-          && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
-              || code1 == ENUMERAL_TYPE))
+      if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE)
+          && (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
        short_compare = 1;
       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
        result_type = composite_pointer_type (type0, type1, op0, op1,
@@ -4817,8 +4799,6 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
       if (val != 0)
        return val;
 
-      arg = mark_lvalue_use (arg);
-
       /* Increment or decrement the real part of the value,
         and don't change the imaginary part.  */
       if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE)
@@ -4952,8 +4932,6 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
 
       argtype = lvalue_type (arg);
 
-      arg = mark_lvalue_use (arg);
-
       if (TREE_CODE (arg) == OFFSET_REF)
        goto offset_ref;
 
@@ -8056,4 +8034,3 @@ lvalue_or_else (tree ref, enum lvalue_use use, tsubst_flags_t complain)
 
   return win;
 }
-