diff options
author | Jason Merrill <jason@redhat.com> | 2016-04-13 16:11:29 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2016-04-13 16:11:29 -0400 |
commit | 2ee35bea2e5f0241fff589ddc038c9d8eb444fb9 (patch) | |
tree | f4446c9a372328e1c80530640ab77106661bfe34 /gcc/cp/decl.c | |
parent | 5655267ca161de13e553dbfc0b7e58962fbb2443 (diff) | |
download | gcc-2ee35bea2e5f0241fff589ddc038c9d8eb444fb9.zip gcc-2ee35bea2e5f0241fff589ddc038c9d8eb444fb9.tar.gz gcc-2ee35bea2e5f0241fff589ddc038c9d8eb444fb9.tar.bz2 |
Warn about empty parameter ABI with -Wabi=9.
* call.c (empty_class_msg, mark_for_abi_warning)
(warn_empty_class_abi): New.
(build_call_a): Use them.
* decl.c (store_parm_decls): Use mark_for_abi_warning.
* error.c (pp_format_to_string): New.
From-SVN: r234960
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5ca426b..7099199 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -14332,16 +14332,34 @@ 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 (parm)) + || !VOID_TYPE_P (type)) 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 { |