aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-04-14 12:23:06 -0400
committerJason Merrill <jason@gcc.gnu.org>2016-04-14 12:23:06 -0400
commit9f285ccb77a109ba94788f71ac83d4d46299ea9f (patch)
tree0d922603fa3db1c9a198d7caeec6b41056443321 /gcc/cp
parent52fbb073e9310d2e1f83a4124a24ec83db1b6fd1 (diff)
downloadgcc-9f285ccb77a109ba94788f71ac83d4d46299ea9f.zip
gcc-9f285ccb77a109ba94788f71ac83d4d46299ea9f.tar.gz
gcc-9f285ccb77a109ba94788f71ac83d4d46299ea9f.tar.bz2
Revert empty class parameter passing ABI changes.
From-SVN: r234977
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/call.c107
-rw-r--r--gcc/cp/cp-tree.h6
-rw-r--r--gcc/cp/decl.c24
-rw-r--r--gcc/cp/error.c22
5 files changed, 11 insertions, 153 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 866b4f2..4267f65 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-14 Jason Merrill <jason@redhat.com>
+
+ * call.c, decl.c, error.c, cp-tree.h, decl.c: Revert empty
+ parameter ABI change.
+
2016-04-13 Martin Sebor <msebor@redhat.com>
PR c++/69517
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 687e7bd..ed23490 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -214,8 +214,6 @@ static void add_candidates (tree, tree, const vec<tree, va_gc> *, tree, tree,
tsubst_flags_t);
static conversion *merge_conversion_sequences (conversion *, conversion *);
static tree build_temp (tree, tree, int, diagnostic_t *, tsubst_flags_t);
-static bool pass_as_empty_struct (tree type);
-static tree empty_class_arg (tree);
/* Returns nonzero iff the destructor name specified in NAME matches BASETYPE.
NAME can take many forms... */
@@ -381,31 +379,16 @@ build_call_a (tree function, int n, tree *argarray)
/* Don't pass empty class objects by value. This is useful
for tags in STL, which are used to control overload resolution.
We don't need to handle other cases of copying empty classes. */
- bool warned = false;
- if (decl && !TREE_PUBLIC (decl))
- /* Don't warn about the ABI of a function local to this TU. */
- warned = true;
- tree empty_arg = NULL_TREE;
if (! decl || ! DECL_BUILT_IN (decl))
for (i = 0; i < n; i++)
{
tree arg = CALL_EXPR_ARG (function, i);
- tree type = TREE_TYPE (arg);
- if (is_really_empty_class (type)
- && ! TREE_ADDRESSABLE (type))
+ if (is_empty_class (TREE_TYPE (arg))
+ && ! TREE_ADDRESSABLE (TREE_TYPE (arg)))
{
- empty_arg = arg;
- CALL_EXPR_ARG (function, i) = empty_class_arg (arg);
- }
- /* Warn about ABI changes for a non-final argument. */
- else if (!warned && empty_arg)
- {
- location_t loc = EXPR_LOC_OR_LOC (empty_arg, input_location);
- if (decl && !varargs_function_p (decl))
- mark_for_abi_warning (decl, empty_arg);
- else
- warn_empty_class_abi (empty_arg, loc);
- warned = true;
+ tree t = build0 (EMPTY_CLASS_EXPR, TREE_TYPE (arg));
+ arg = build2 (COMPOUND_EXPR, TREE_TYPE (t), arg, t);
+ CALL_EXPR_ARG (function, i) = arg;
}
}
@@ -6889,15 +6872,6 @@ build_x_va_arg (source_location loc, tree expr, tree type)
expr = build_va_arg (loc, expr, ref);
return convert_from_reference (expr);
}
- else if (is_really_empty_class (type) && !TREE_ADDRESSABLE (type))
- {
- /* Do the reverse of empty_class_arg. */
- tree etype = pass_as_empty_struct (type) ? empty_struct_type : type;
- expr = build_va_arg (loc, expr, etype);
- warn_empty_class_abi (type, loc);
- tree ec = build0 (EMPTY_CLASS_EXPR, type);
- return build2 (COMPOUND_EXPR, type, expr, ec);
- }
return build_va_arg (loc, expr, type);
}
@@ -6994,75 +6968,6 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum,
return arg;
}
-/* Return true iff TYPE should be passed and returned as a size 0 type rather
- than its normal size, for compatibility with C. */
-
-static bool
-pass_as_empty_struct (tree type)
-{
- return (abi_version_at_least (10)
- && type != error_mark_node
- && COMPLETE_TYPE_P (type)
- && !TREE_ADDRESSABLE (type)
- && is_really_empty_class (type));
-}
-
-/* Adjust the value VAL of empty class type TYPE for argument passing.
- Keep this synced with build_x_va_arg. */
-
-static tree
-empty_class_arg (tree val)
-{
- /* Don't pass empty class objects by value. This is useful
- for tags in STL, which are used to control overload resolution.
- We don't need to handle other cases of copying empty classes. */
- tree type = TREE_TYPE (val);
- tree etype = pass_as_empty_struct (type) ? empty_struct_type : type;
- tree empty = build0 (EMPTY_CLASS_EXPR, etype);
- return build2 (COMPOUND_EXPR, etype, val, empty);
-}
-
-/* Generate a message warning about the change in empty class parameter passing
- ABI. */
-
-static tree
-empty_class_msg (tree type)
-{
- if (!TYPE_P (type))
- type = TREE_TYPE (type);
-
- return pp_format_to_string ("empty class %qT parameter passing ABI "
- "changes in -fabi-version=10 (GCC 6)", type);
-}
-
-/* Warn immediately about the change in empty class parameter ABI. */
-
-void
-warn_empty_class_abi (tree arg, location_t loc)
-{
- if (!warn_abi || !abi_version_crosses (10))
- return;
-
- warning_at (loc, OPT_Wabi, "%E", empty_class_msg (arg));
-}
-
-/* Tack a warning about the change in empty class parameter ABI onto FN, so
- that we get a warning if a definition or call is emitted. */
-
-void
-mark_for_abi_warning (tree fn, tree type)
-{
- if (!warn_abi || !abi_version_crosses (10))
- return;
- if (lookup_attribute ("abi warning", DECL_ATTRIBUTES (fn)))
- return;
-
- tree msg = empty_class_msg (type);
- msg = build_tree_list (NULL_TREE, msg);
- DECL_ATTRIBUTES (fn) = tree_cons (get_identifier ("abi warning"), msg,
- DECL_ATTRIBUTES (fn));
-}
-
/* Returns the type which will really be used for passing an argument of
type TYPE. */
@@ -7081,8 +6986,6 @@ type_passed_as (tree type)
&& COMPLETE_TYPE_P (type)
&& tree_int_cst_lt (TYPE_SIZE (type), TYPE_SIZE (integer_type_node)))
type = integer_type_node;
- else if (pass_as_empty_struct (type))
- type = empty_struct_type;
return type;
}
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 87e3ea0..baff674 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1150,8 +1150,6 @@ enum cp_tree_index
CPTI_NULLPTR,
CPTI_NULLPTR_TYPE,
- CPTI_EMPTY_STRUCT,
-
CPTI_MAX
};
@@ -1187,7 +1185,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
#define current_aggr cp_global_trees[CPTI_AGGR_TAG]
#define nullptr_node cp_global_trees[CPTI_NULLPTR]
#define nullptr_type_node cp_global_trees[CPTI_NULLPTR_TYPE]
-#define empty_struct_type cp_global_trees[CPTI_EMPTY_STRUCT]
/* We cache these tree nodes so as to call get_identifier less
frequently. */
@@ -5540,8 +5537,6 @@ extern tree build_addr_func (tree, tsubst_flags_t);
extern void set_flags_from_callee (tree);
extern tree build_call_a (tree, int, tree*);
extern tree build_call_n (tree, int, ...);
-extern void mark_for_abi_warning (tree, tree);
-extern void warn_empty_class_abi (tree, location_t);
extern bool null_ptr_cst_p (tree);
extern bool null_member_pointer_value_p (tree);
extern bool sufficient_parms_p (const_tree);
@@ -5896,7 +5891,6 @@ extern bool pedwarn_cxx98 (location_t, int, const char *,
extern location_t location_of (tree);
extern void qualified_name_lookup_error (tree, tree, tree,
location_t);
-extern tree pp_format_to_string (const char *, ...);
/* in except.c */
extern void init_exception_processing (void);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 42e853f..65b5733 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4180,10 +4180,6 @@ cxx_init_decl_processing (void)
nullptr_node = build_int_cst (nullptr_type_node, 0);
}
- empty_struct_type = make_node (RECORD_TYPE);
- finish_builtin_struct (empty_struct_type, "__empty_struct",
- NULL_TREE, NULL_TREE);
-
abort_fndecl
= build_library_fn_ptr ("__cxa_pure_virtual", void_ftype,
ECF_NORETURN | ECF_NOTHROW);
@@ -14375,34 +14371,16 @@ store_parm_decls (tree current_function_parms)
they end in the correct forward order. */
specparms = nreverse (specparms);
- /* Don't warn about the ABI of a function local to this TU. */
- bool warned = !TREE_PUBLIC (current_function_decl);
- bool saw_nonempty = false;
for (parm = specparms; parm; parm = next)
{
next = DECL_CHAIN (parm);
if (TREE_CODE (parm) == PARM_DECL)
{
- tree type = TREE_TYPE (parm);
if (DECL_NAME (parm) == NULL_TREE
- || !VOID_TYPE_P (type))
+ || !VOID_TYPE_P (parm))
pushdecl (parm);
else
error ("parameter %qD declared void", parm);
- /* If this isn't the last parameter, maybe warn about ABI change
- in passing empty classes. */
- if (processing_template_decl)
- continue;
- if (TREE_ADDRESSABLE (type)
- || !is_really_empty_class (type))
- saw_nonempty = true;
- else if (!warned
- && (saw_nonempty
- || varargs_function_p (current_function_decl)))
- {
- mark_for_abi_warning (current_function_decl, type);
- warned = true;
- }
}
else
{
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 5aaa177..aa5fd41 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -3718,25 +3718,3 @@ qualified_name_lookup_error (tree scope, tree name,
suggest_alternatives_for (location, name);
}
}
-
-/* Like error et al, but return the formatted message as a STRING_CST. */
-
-tree
-pp_format_to_string (const char *msg, ...)
-{
- pretty_printer *pp = global_dc->printer;
- text_info text;
- va_list ap;
-
- va_start (ap, msg);
- text.err_no = errno;
- text.args_ptr = &ap;
- text.format_spec = msg;
- pp_format (pp, &text);
- pp_output_formatted_text (pp);
- va_end (ap);
- const char *fmt = pp_formatted_text (pp);
- tree str = build_string (strlen (fmt) + 1, fmt);
- pp_clear_output_area (pp);
- return str;
-}