Since construct_container may be called with cfun == NULL, check
cfun != NULL before accessing silent_p.
gcc/
PR target/99679
* config/i386/i386.c (construct_container): Check cfun != NULL
before accessing silent_p.
gcc/testsuite/
PR target/99679
* g++.target/i386/pr99679-1.C: New test.
* g++.target/i386/pr99679-2.C: Likewise.
{
/* Return early if we shouldn't raise an error for invalid
calls. */
- if (cfun->machine->silent_p)
+ if (cfun != NULL && cfun->machine->silent_p)
return NULL;
if (in_return)
{
{
/* Return early if we shouldn't raise an error for invalid
calls. */
- if (cfun->machine->silent_p)
+ if (cfun != NULL && cfun->machine->silent_p)
return NULL;
if (!issued_x87_ret_error)
{
--- /dev/null
+// { dg-do compile }
+// { dg-options "-Ofast -fipa-pta -mno-80387" }
+
+#include <stdarg.h>
+
+extern "C" void abort (void);
+
+void
+foo (int x, ...)
+{
+ long double ld;
+ va_list ap;
+ va_start (ap, x);
+ ld = va_arg (ap, long double);
+ if (ld)
+ abort ();
+} // { dg-error "x87 register return with x87 disabled" "" { target { ! ia32 } } }
--- /dev/null
+// { dg-do compile }
+// { dg-options "-Ofast -fipa-pta -mgeneral-regs-only" }
+
+#include <stdarg.h>
+
+extern "C" void abort (void);
+
+void
+foo (int x, ...)
+{
+ double ld;
+ va_list ap;
+ va_start (ap, x);
+ ld = va_arg (ap, double); // { dg-error "SSE register argument with SSE disabled" "" { target { ! ia32 } } }
+ if (ld)
+ abort ();
+} // { dg-error "SSE register return with SSE disabled" "" { target { ! ia32 } } }