&& is_std_construct_at (call->fundef->decl));
}
-/* True if CTX is an instance of std::allocator. */
+/* True if CTX is an instance of std::NAME class. */
bool
-is_std_allocator (tree ctx)
+is_std_class (tree ctx, const char *name)
{
if (ctx == NULL_TREE || !CLASS_TYPE_P (ctx) || !TYPE_MAIN_DECL (ctx))
return false;
tree decl = TYPE_MAIN_DECL (ctx);
- tree name = DECL_NAME (decl);
- if (name == NULL_TREE || !id_equal (name, "allocator"))
+ tree dname = DECL_NAME (decl);
+ if (dname == NULL_TREE || !id_equal (dname, name))
return false;
return decl_in_std_namespace_p (decl);
}
+/* True if CTX is an instance of std::allocator. */
+
+bool
+is_std_allocator (tree ctx)
+{
+ return is_std_class (ctx, "allocator");
+}
+
/* Return true if FNDECL is std::allocator<T>::{,de}allocate. */
static inline bool
extern bool is_nondependent_constant_expression (tree);
extern bool is_nondependent_static_init_expression (tree);
extern bool is_static_init_expression (tree);
+extern bool is_std_class (tree, const char *);
extern bool is_std_allocator (tree);
extern bool potential_rvalue_constant_expression (tree);
extern bool require_potential_constant_expression (tree);
}
}
+ /* Check for replaceable global new/delete operators with
+ const std::nothrow_t & last argument, other replaceable global
+ new/delete operators are marked in cxx_init_decl_processing. */
+ if (CP_DECL_CONTEXT (decl) == global_namespace)
+ {
+ tree args = argtypes;
+ if (args
+ && args != void_list_node
+ && same_type_p (TREE_VALUE (args),
+ (op_flags & OVL_OP_FLAG_DELETE)
+ ? ptr_type_node : size_type_node))
+ {
+ args = TREE_CHAIN (args);
+ if (aligned_allocation_fn_p (decl))
+ args = TREE_CHAIN (args);
+ if (args
+ && args != void_list_node
+ && TREE_CHAIN (args) == void_list_node)
+ {
+ tree t = TREE_VALUE (args);
+ if (TYPE_REF_P (t)
+ && !TYPE_REF_IS_RVALUE (t)
+ && (t = TREE_TYPE (t))
+ && TYPE_QUALS (t) == TYPE_QUAL_CONST
+ && is_std_class (t, "nothrow_t"))
+ DECL_IS_REPLACEABLE_OPERATOR (decl) = 1;
+ }
+ }
+ }
+
if (op_flags & OVL_OP_FLAG_DELETE)
{
DECL_SET_IS_OPERATOR_DELETE (decl, true);