This avoids crashes with __builtin_next_arg on non-parameters. For
the specific testcase we arrive with an anonymous SSA_NAME so that
SSA_NAME_VAR becomes NULL and we crash.
2021-02-24 Richard Biener <rguenther@suse.de>
PR c/99224
* builtins.c (fold_builtin_next_arg): Avoid NULL arg.
* gcc.dg/pr99224.c: New testcase.
arg = CALL_EXPR_ARG (exp, 0);
}
- if (TREE_CODE (arg) == SSA_NAME)
+ if (TREE_CODE (arg) == SSA_NAME
+ && SSA_NAME_VAR (arg))
arg = SSA_NAME_VAR (arg);
/* We destructively modify the call to be __builtin_va_start (ap, 0)
--- /dev/null
+/* { dg-do compile } */
+
+void f (char *c, ...)
+{
+ __builtin_next_arg (*c); /* { dg-warning "not last named argument" } */
+}