call.c (build_op_delete_call, [...]): Check mark_used return value.
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 16 Apr 2015 15:12:10 +0000 (15:12 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 16 Apr 2015 15:12:10 +0000 (15:12 +0000)
2015-04-16  Paolo Carlini  <paolo.carlini@oracle.com>

* call.c (build_op_delete_call, build_over_call): Check mark_used
return value.
* class.c (resolve_address_of_overloaded_function): Likewise.
* decl.c (cxx_maybe_build_cleanup): Likewise.
* pt.c (gen_elem_of_pack_expansion_instantiation, tsubst_baselink,
tsubst_qualified_id, tsubst_copy, tsubst_copy_and_build): Likewise.
* rtti.c (build_dynamic_cast_1): Likewise.
* semantics.c (process_outer_var_ref): Likewise.
* typeck.c (build_class_member_access_expr,
cp_build_function_call_vec, cp_build_addr_expr_1): Likewise.

From-SVN: r222150

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/class.c
gcc/cp/decl.c
gcc/cp/pt.c
gcc/cp/rtti.c
gcc/cp/semantics.c
gcc/cp/typeck.c

index bbfba2b..65b5ed9 100644 (file)
@@ -1,3 +1,16 @@
+2015-04-16  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * call.c (build_op_delete_call, build_over_call): Check mark_used
+       return value.
+       * class.c (resolve_address_of_overloaded_function): Likewise.
+       * decl.c (cxx_maybe_build_cleanup): Likewise.
+       * pt.c (gen_elem_of_pack_expansion_instantiation, tsubst_baselink,
+       tsubst_qualified_id, tsubst_copy, tsubst_copy_and_build): Likewise.
+       * rtti.c (build_dynamic_cast_1): Likewise.
+       * semantics.c (process_outer_var_ref): Likewise.
+       * typeck.c (build_class_member_access_expr,
+       cp_build_function_call_vec, cp_build_addr_expr_1): Likewise.
+
 2015-04-15  Jason Merrill  <jason@redhat.com>
 
        * constexpr.c (cxx_eval_store_expression): Ignore clobbers.
index c9ecc16..7bdf236 100644 (file)
@@ -5968,7 +5968,8 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
          argarray[0] = addr;
          for (i = 1; i < nargs; i++)
            argarray[i] = CALL_EXPR_ARG (placement, i);
-         mark_used (fn);
+         if (!mark_used (fn, complain) && !(complain & tf_error))
+           return error_mark_node;
          return build_cxx_call (fn, nargs, argarray, complain);
        }
       else
@@ -7400,7 +7401,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
         the implementation elided its use.  */
       if (!trivial || DECL_DELETED_FN (fn))
        {
-         mark_used (fn);
+         if (!mark_used (fn, complain) && !(complain & tf_error))
+           return error_mark_node;
          already_used = true;
        }
 
index 9f189fb..fde51c5 100644 (file)
@@ -7755,8 +7755,8 @@ resolve_address_of_overloaded_function (tree target_type,
       /* Make =delete work with SFINAE.  */
       if (DECL_DELETED_FN (fn) && !(flags & tf_error))
        return error_mark_node;
-      
-      mark_used (fn);
+      if (!mark_used (fn, flags) && !(flags & tf_error))
+       return error_mark_node;
     }
 
   /* We could not check access to member functions when this
index 965f07c..b920fe7 100644 (file)
@@ -14587,7 +14587,8 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain)
         ordinary FUNCTION_DECL.  */
       fn = lookup_name (id);
       arg = build_address (decl);
-      mark_used (decl);
+      if (!mark_used (decl, complain) && !(complain & tf_error))
+       return error_mark_node;
       cleanup = cp_build_function_call_nary (fn, complain, arg, NULL_TREE);
       if (cleanup == error_mark_node)
        return error_mark_node;
@@ -14627,10 +14628,11 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain)
     SET_EXPR_LOCATION (cleanup, UNKNOWN_LOCATION);
 
   if (cleanup
-      && !lookup_attribute ("warn_unused", TYPE_ATTRIBUTES (TREE_TYPE (decl))))
-    /* Treat objects with destructors as used; the destructor may do
-       something substantive.  */
-    mark_used (decl);
+      && !lookup_attribute ("warn_unused", TYPE_ATTRIBUTES (TREE_TYPE (decl)))
+      /* Treat objects with destructors as used; the destructor may do
+        something substantive.  */
+      && !mark_used (decl, complain) && !(complain & tf_error))
+    return error_mark_node;
 
   return cleanup;
 }
index aed6f1c..91e56a5 100644 (file)
@@ -9833,7 +9833,8 @@ gen_elem_of_pack_expansion_instantiation (tree pattern,
          if (index == 0)
            {
              aps = make_argument_pack_select (arg_pack, index);
-             mark_used (parm);
+             if (!mark_used (parm, complain) && !(complain & tf_error))
+               return error_mark_node;
              register_local_specialization (aps, parm);
            }
          else
@@ -12603,8 +12604,9 @@ tsubst_baselink (tree baselink, tree object_type,
        point.)  */
     if (BASELINK_P (baselink))
       fns = BASELINK_FUNCTIONS (baselink);
-    if (!template_id_p && !really_overloaded_fn (fns))
-      mark_used (OVL_CURRENT (fns));
+    if (!template_id_p && !really_overloaded_fn (fns)
+       && !mark_used (OVL_CURRENT (fns), complain) && !(complain & tf_error))
+      return error_mark_node;
 
     /* Add back the template arguments, if present.  */
     if (BASELINK_P (baselink) && template_id_p)
@@ -12719,7 +12721,8 @@ tsubst_qualified_id (tree qualified_id, tree args,
       check_accessibility_of_qualified_id (expr, /*object_type=*/NULL_TREE,
                                           scope);
       /* Remember that there was a reference to this entity.  */
-      mark_used (expr);
+      if (!mark_used (expr, complain) && !(complain & tf_error))
+       return error_mark_node;
     }
 
   if (expr == error_mark_node || TREE_CODE (expr) == TREE_LIST)
@@ -12829,7 +12832,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
       
       if (TREE_CODE (r) == ARGUMENT_PACK_SELECT)
        r = ARGUMENT_PACK_SELECT_ARG (r);
-      mark_used (r);
+      if (!mark_used (r, complain) && !(complain & tf_error))
+       return error_mark_node;
       return r;
 
     case CONST_DECL:
@@ -12986,7 +12990,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
        }
       else
        r = t;
-      mark_used (r);
+      if (!mark_used (r, complain) && !(complain & tf_error))
+       return error_mark_node;
       return r;
 
     case NAMESPACE_DECL:
@@ -13350,7 +13355,9 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
        tree op1 = tsubst_copy (TREE_OPERAND (t, 1), args, complain, in_decl);
        r = build2 (code, type, op0, op1);
        PTRMEM_OK_P (r) = PTRMEM_OK_P (t);
-       mark_used (TREE_OPERAND (r, 1));
+       if (!mark_used (TREE_OPERAND (r, 1), complain)
+           && !(complain & tf_error))
+         return error_mark_node;
        return r;
       }
 
@@ -14868,8 +14875,9 @@ tsubst_copy_and_build (tree t,
       op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0),
                                                args, complain, in_decl);
       /* Remember that there was a reference to this entity.  */
-      if (DECL_P (op1))
-       mark_used (op1);
+      if (DECL_P (op1)
+         && !mark_used (op1, complain) && !(complain & tf_error))
+       RETURN (error_mark_node);
       RETURN (build_x_arrow (input_location, op1, complain));
 
     case NEW_EXPR:
@@ -15120,8 +15128,9 @@ tsubst_copy_and_build (tree t,
          }
 
        /* Remember that there was a reference to this entity.  */
-       if (DECL_P (function))
-         mark_used (function, complain);
+       if (DECL_P (function)
+           && !mark_used (function, complain) && !(complain & tf_error))
+         RETURN (error_mark_node);
 
        /* Put back tf_decltype for the actual call.  */
        complain |= decltype_flag;
@@ -15304,8 +15313,9 @@ tsubst_copy_and_build (tree t,
        object = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0),
                                                     args, complain, in_decl);
        /* Remember that there was a reference to this entity.  */
-       if (DECL_P (object))
-         mark_used (object);
+       if (DECL_P (object)
+           && !mark_used (object, complain) && !(complain & tf_error))
+         RETURN (error_mark_node);
        object_type = TREE_TYPE (object);
 
        member = TREE_OPERAND (t, 1);
index 3e941b9..8200d30 100644 (file)
@@ -708,10 +708,12 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain)
          target_type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
          static_type = TYPE_MAIN_VARIANT (TREE_TYPE (exprtype));
          td2 = get_tinfo_decl (target_type);
-         mark_used (td2);
+         if (!mark_used (td2, complain) && !(complain & tf_error))
+           return error_mark_node;
          td2 = cp_build_addr_expr (td2, complain);
          td3 = get_tinfo_decl (static_type);
-         mark_used (td3);
+         if (!mark_used (td3, complain) && !(complain & tf_error))
+           return error_mark_node;
          td3 = cp_build_addr_expr (td3, complain);
 
          /* Determine how T and V are related.  */
index 74af7e8..0fc08b5 100644 (file)
@@ -3117,7 +3117,8 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain)
   tree initializer = convert_from_reference (decl);
 
   /* Mark it as used now even if the use is ill-formed.  */
-  mark_used (decl);
+  if (!mark_used (decl, complain) && !(complain & tf_error))
+    return error_mark_node;
 
   /* Core issue 696: "[At the July 2009 meeting] the CWG expressed
      support for an approach in which a reference to a local
index e9d4cae..250b5d6 100644 (file)
@@ -2298,7 +2298,8 @@ build_class_member_access_expr (tree object, tree member,
   if (DECL_P (member))
     {
       member_scope = DECL_CLASS_CONTEXT (member);
-      mark_used (member);
+      if (!mark_used (member, complain) && !(complain & tf_error))
+       return error_mark_node;
       if (TREE_DEPRECATED (member))
        warn_deprecated_use (member, NULL_TREE);
     }
@@ -3477,7 +3478,8 @@ cp_build_function_call_vec (tree function, vec<tree, va_gc> **params,
 
   if (TREE_CODE (function) == FUNCTION_DECL)
     {
-      mark_used (function);
+      if (!mark_used (function, complain) && !(complain & tf_error))
+       return error_mark_node;
       fndecl = function;
 
       /* Convert anything with function type to a pointer-to-function.  */
@@ -5376,7 +5378,8 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
         and the created OFFSET_REF.  */
       tree base = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg, 0)));
       tree fn = get_first_fn (TREE_OPERAND (arg, 1));
-      mark_used (fn);
+      if (!mark_used (fn, complain) && !(complain & tf_error))
+       return error_mark_node;
 
       if (! flag_ms_extensions)
        {
@@ -5563,7 +5566,8 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
         function.  */
       gcc_assert (TREE_CODE (fn) == FUNCTION_DECL
                  && DECL_STATIC_FUNCTION_P (fn));
-      mark_used (fn);
+      if (!mark_used (fn, complain) && !(complain & tf_error))
+       return error_mark_node;
       val = build_address (fn);
       if (TREE_SIDE_EFFECTS (TREE_OPERAND (arg, 0)))
        /* Do not lose object's side effects.  */