diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-08-11 16:46:49 +0200 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-17 15:07:58 -0300 |
commit | ef19de71aa17c58bee6e839ae3334bbbda424b06 (patch) | |
tree | bdb18e41861615720499967e103ab357472ea740 /gcc/testsuite | |
parent | 58b741b1bf1127946a0590d909302023c2350bb5 (diff) |
c-family: Fix ICE in get_atomic_generic_size [PR96545]
As the testcase shows, we would ICE if the type of the first argument of
various atomic builtins was pointer to (non-void) incomplete type, we would
assume that TYPE_SIZE_UNIT must be non-NULL. This patch diagnoses it
instead. And also changes the TREE_CODE != INTEGER_CST check to
!tree_fits_uhwi_p, as we use tree_to_uhwi after this and at least in theory
the int could be too large and not fit.
2020-08-11 Jakub Jelinek <jakub@redhat.com>
PR c/96545
* c-common.c (get_atomic_generic_size): Require that first argument's
type points to a complete type and use tree_fits_uhwi_p instead of
just INTEGER_CST TREE_CODE check for the TYPE_SIZE_UNIT.
* c-c++-common/pr96545.c: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/c-c++-common/pr96545.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/pr96545.c b/gcc/testsuite/c-c++-common/pr96545.c new file mode 100644 index 00000000000..bc6b0cf345c --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr96545.c @@ -0,0 +1,31 @@ +/* PR c/96545 */ +/* { dg-do compile } */ + +extern char x[], y[], z[]; +struct S; +extern struct S s, t, u; +int v, w; + +void +foo (void) +{ + __atomic_exchange (&x, &y, &z, 0); /* { dg-error "must be a pointer to a complete type" } */ +} + +void +bar (void) +{ + __atomic_exchange (&s, &t, &u, 0); /* { dg-error "must be a pointer to a complete type" } */ +} + +void +baz (void) +{ + __atomic_exchange (&v, &t, &w, 0); /* { dg-error "size mismatch in argument 2 of" } */ +} + +void +qux (void) +{ + __atomic_exchange (&v, &w, &t, 0); /* { dg-error "size mismatch in argument 3 of" } */ +} |