diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-13 20:11:29 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-13 20:11:29 +0000 |
commit | 25c036a76d946bbac4c81da270068b996b81f33d (patch) | |
tree | f4446c9a372328e1c80530640ab77106661bfe34 /gcc/cp/decl.c | |
parent | 9d81feb8813a8790504fb608bd9e50b5543879ee (diff) | |
download | gcc-25c036a76d946bbac4c81da270068b996b81f33d.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234960 138bc75d-0d04-0410-961f-82ee72b054a4
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 5ca426bbd03..7099199dea3 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 { |