+2016-09-10 Tom de Vries <tom@codesourcery.com>
+
+ PR C/71602
+ * builtins.c (std_canonical_va_list_type): Strictly return non-null for
+ va_list type only.
+ * config/i386/i386.c (ix86_canonical_va_list_type): Same.
+ * gimplify.c (gimplify_va_arg_expr): Handle &va_list.
+
2016-09-09 Peter Bergner <bergner@vnet.ibm.com>
PR rtl-optimization/77289
{
tree wtype, htype;
- if (INDIRECT_REF_P (type))
- type = TREE_TYPE (type);
- else if (POINTER_TYPE_P (type) && POINTER_TYPE_P (TREE_TYPE (type)))
- type = TREE_TYPE (type);
wtype = va_list_type_node;
htype = type;
/* Treat structure va_list types. */
+2016-09-10 Tom de Vries <tom@codesourcery.com>
+
+ PR C/71602
+ * c-common.c (build_va_arg): Handle more strict
+ targetm.canonical_va_list_type. Replace first argument type error with
+ assert.
+
2016-09-09 Martin Sebor <msebor@redhat.com>
PR c/77520
{
/* Case 1: Not an array type. */
- /* Take the address, to get '&ap'. */
+ /* Take the address, to get '&ap'. Note that &ap is not a va_list
+ type. */
mark_addressable (expr);
expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (expr)), expr);
- /* Verify that &ap is still recognized as having va_list type. */
- tree canon_expr_type
- = targetm.canonical_va_list_type (TREE_TYPE (expr));
- if (canon_expr_type == NULL_TREE)
- {
- error_at (loc,
- "first argument to %<va_arg%> not of type %<va_list%>");
- return error_mark_node;
- }
-
return build_va_arg_1 (loc, type, expr);
}
/* Verify that &ap is still recognized as having va_list type. */
tree canon_expr_type
= targetm.canonical_va_list_type (TREE_TYPE (expr));
- if (canon_expr_type == NULL_TREE)
- {
- error_at (loc,
- "first argument to %<va_arg%> not of type %<va_list%>");
- return error_mark_node;
- }
+ gcc_assert (canon_expr_type != NULL_TREE);
}
else
{
static tree
ix86_canonical_va_list_type (tree type)
{
- /* Resolve references and pointers to va_list type. */
- if (TREE_CODE (type) == MEM_REF)
- type = TREE_TYPE (type);
- else if (POINTER_TYPE_P (type) && POINTER_TYPE_P (TREE_TYPE(type)))
- type = TREE_TYPE (type);
- else if (POINTER_TYPE_P (type) && TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE)
- type = TREE_TYPE (type);
-
if (TARGET_64BIT)
{
if (lookup_attribute ("ms_abi va_list", TYPE_ATTRIBUTES (type)))
if (have_va_type == error_mark_node)
return GS_ERROR;
have_va_type = targetm.canonical_va_list_type (have_va_type);
+ if (have_va_type == NULL_TREE
+ && TREE_CODE (valist) == ADDR_EXPR)
+ /* Handle 'Case 1: Not an array type' from c-common.c/build_va_arg. */
+ have_va_type
+ = targetm.canonical_va_list_type (TREE_TYPE (TREE_TYPE (valist)));
gcc_assert (have_va_type != NULL_TREE);
/* Generate a diagnostic for requesting data of a type that cannot
+2016-09-10 Tom de Vries <tom@codesourcery.com>
+
+ PR C/71602
+ * c-c++-common/va-arg-va-list-type.c: New test.
+
2016-09-09 Peter Bergner <bergner@vnet.ibm.com>
PR rtl-optimization/77289
--- /dev/null
+/* { dg-do compile } */
+
+__builtin_va_list *pap;
+
+void
+fn1 (void)
+{
+ __builtin_va_arg (pap, double); /* { dg-error "first argument to 'va_arg' not of type 'va_list'" } */
+}