diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-03-20 05:17:36 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-03-20 10:08:31 -0700 |
commit | 19ff0b0d816e6e7d7657a8559e9957d79dc1d77f (patch) | |
tree | 334a73f2effa41f2a2048f27edeb53d94be12568 | |
parent | 9f59cb7cac009f3c6eba81eb09714699b9ac9f8d (diff) | |
download | gcc-19ff0b0d816e6e7d7657a8559e9957d79dc1d77f.zip gcc-19ff0b0d816e6e7d7657a8559e9957d79dc1d77f.tar.gz gcc-19ff0b0d816e6e7d7657a8559e9957d79dc1d77f.tar.bz2 |
x86: Check cfun != NULL before accessing silent_p
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.
-rw-r--r-- | gcc/config/i386/i386.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.target/i386/pr99679-1.C | 17 | ||||
-rw-r--r-- | gcc/testsuite/g++.target/i386/pr99679-2.C | 17 |
3 files changed, 36 insertions, 2 deletions
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 7143490..7c41302 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2540,7 +2540,7 @@ construct_container (machine_mode mode, machine_mode orig_mode, { /* 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) { @@ -2568,7 +2568,7 @@ construct_container (machine_mode mode, machine_mode orig_mode, { /* 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) { diff --git a/gcc/testsuite/g++.target/i386/pr99679-1.C b/gcc/testsuite/g++.target/i386/pr99679-1.C new file mode 100644 index 0000000..36640a4 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr99679-1.C @@ -0,0 +1,17 @@ +// { 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 } } } diff --git a/gcc/testsuite/g++.target/i386/pr99679-2.C b/gcc/testsuite/g++.target/i386/pr99679-2.C new file mode 100644 index 0000000..cbd3c49 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr99679-2.C @@ -0,0 +1,17 @@ +// { 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 } } } |