aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>1999-10-13 08:49:54 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>1999-10-13 08:49:54 +0000
commit356955cfb5f78224bc8c6d085d02d904ba84b4aa (patch)
tree0e448901aa69335285ee8574f6046b97ac436ba0 /gcc/cp/call.c
parenta5037588b493c6a1ca654f3acf8a5280cb614bfc (diff)
downloadgcc-356955cfb5f78224bc8c6d085d02d904ba84b4aa.zip
gcc-356955cfb5f78224bc8c6d085d02d904ba84b4aa.tar.gz
gcc-356955cfb5f78224bc8c6d085d02d904ba84b4aa.tar.bz2
cp-tree.h (build_x_va_arg): Prototype new function.
* cp-tree.h (build_x_va_arg): Prototype new function. * call.c (build_x_va_arg): Define it. * parse.y (unary_expr): Call build_x_va_arg. * cp-tree.h (convert_type_from_ellipsis): Prototype new function. * call.c (convert_type_from_ellipsis): Define it. * decl.c (init_decl_processing): Set lang_type_promotes_to. * tree.c (lvalue_p_1): Accept VA_ARG_EXPR with aggregates. From-SVN: r29942
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 6eaf61e..dd4e442 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3813,6 +3813,48 @@ convert_arg_to_ellipsis (arg)
return arg;
}
+/* va_arg (EXPR, TYPE) is a builtin. Make sure it is not abused. */
+
+tree
+build_x_va_arg (expr, type)
+ tree expr;
+ tree type;
+{
+ type = complete_type_or_else (type, NULL_TREE);
+
+ if (expr == error_mark_node || !type)
+ return error_mark_node;
+
+ if (! pod_type_p (type))
+ {
+ /* Undefined behaviour [expr.call] 5.2.2/7. */
+ cp_warning ("cannot receive objects of non-POD type `%#T' through `...'",
+ type);
+ }
+
+ return build_va_arg (expr, type);
+}
+
+/* TYPE has been given to va_arg. Apply the default conversions which would
+ have happened when passed via ellipsis. Return the promoted type, or
+ NULL_TREE, if there is no change. */
+
+tree
+convert_type_from_ellipsis (type)
+ tree type;
+{
+ tree promote;
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ promote = build_pointer_type (TREE_TYPE (type));
+ else if (TREE_CODE (type) == FUNCTION_TYPE)
+ promote = build_pointer_type (type);
+ else
+ promote = type_promotes_to (type);
+
+ return same_type_p (type, promote) ? NULL_TREE : promote;
+}
+
/* ARG is a default argument expression being passed to a parameter of
the indicated TYPE, which is a parameter to FN. Do any required
conversions. Return the converted value. */