diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-09-16 20:39:47 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-09-16 20:39:47 +0200 |
commit | b0bbde7311f92e56f369172e5b9e1513341f618e (patch) | |
tree | fdff82eaeba083f1408c622c04a1bafbbcecac14 | |
parent | f719df942b81b24e005850d31ffed9b2097486f8 (diff) | |
download | gcc-b0bbde7311f92e56f369172e5b9e1513341f618e.zip gcc-b0bbde7311f92e56f369172e5b9e1513341f618e.tar.gz gcc-b0bbde7311f92e56f369172e5b9e1513341f618e.tar.bz2 |
backport: re PR target/82112 (internal compiler error: in fold_convert_loc, at fold-const.c:2262)
Backported from mainline
2017-09-12 Jakub Jelinek <jakub@redhat.com>
PR target/82112
* c-common.c (sync_resolve_size): Instead of c_dialect_cxx ()
assertion check that in the condition.
(get_atomic_generic_size): Likewise. Before testing if parameter
has pointer type, if it has array type, call for C++
default_conversion to perform array-to-pointer conversion.
* c-c++-common/pr82112.c: New test.
* gcc.dg/pr82112.c: New test.
From-SVN: r252886
-rw-r--r-- | gcc/c-family/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr82112.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr82112.c | 21 |
5 files changed, 57 insertions, 4 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index bbe467d..1d3f3bb 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,6 +1,15 @@ 2017-09-16 Jakub Jelinek <jakub@redhat.com> Backported from mainline + 2017-09-12 Jakub Jelinek <jakub@redhat.com> + + PR target/82112 + * c-common.c (sync_resolve_size): Instead of c_dialect_cxx () + assertion check that in the condition. + (get_atomic_generic_size): Likewise. Before testing if parameter + has pointer type, if it has array type, call for C++ + default_conversion to perform array-to-pointer conversion. + 2017-07-27 Jakub Jelinek <jakub@redhat.com> PR c/45784 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 3524570..4a1c2e4 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -10534,10 +10534,9 @@ sync_resolve_size (tree function, vec<tree, va_gc> *params) } type = TREE_TYPE ((*params)[0]); - if (TREE_CODE (type) == ARRAY_TYPE) + if (TREE_CODE (type) == ARRAY_TYPE && c_dialect_cxx ()) { /* Force array-to-pointer decay for C++. */ - gcc_assert (c_dialect_cxx()); (*params)[0] = default_conversion ((*params)[0]); type = TREE_TYPE ((*params)[0]); } @@ -10692,10 +10691,9 @@ get_atomic_generic_size (location_t loc, tree function, /* Get type of first parameter, and determine its size. */ type_0 = TREE_TYPE ((*params)[0]); - if (TREE_CODE (type_0) == ARRAY_TYPE) + if (TREE_CODE (type_0) == ARRAY_TYPE && c_dialect_cxx ()) { /* Force array-to-pointer decay for C++. */ - gcc_assert (c_dialect_cxx()); (*params)[0] = default_conversion ((*params)[0]); type_0 = TREE_TYPE ((*params)[0]); } @@ -10734,6 +10732,12 @@ get_atomic_generic_size (location_t loc, tree function, /* __atomic_compare_exchange has a bool in the 4th position, skip it. */ if (n_param == 6 && x == 3) continue; + if (TREE_CODE (type) == ARRAY_TYPE && c_dialect_cxx ()) + { + /* Force array-to-pointer decay for C++. */ + (*params)[x] = default_conversion ((*params)[x]); + type = TREE_TYPE ((*params)[x]); + } if (!POINTER_TYPE_P (type)) { error_at (loc, "argument %d of %qE must be a pointer type", x + 1, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 853812a..be66391 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,12 @@ 2017-09-16 Jakub Jelinek <jakub@redhat.com> Backported from mainline + 2017-09-12 Jakub Jelinek <jakub@redhat.com> + + PR target/82112 + * c-c++-common/pr82112.c: New test. + * gcc.dg/pr82112.c: New test. + 2017-08-08 Richard Biener <rguenther@suse.de> PR middle-end/81766 diff --git a/gcc/testsuite/c-c++-common/pr82112.c b/gcc/testsuite/c-c++-common/pr82112.c new file mode 100644 index 0000000..724d74c --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr82112.c @@ -0,0 +1,13 @@ +/* PR target/82112 */ +/* { dg-do compile } */ + +int c[10], d[10], e[10], f[10], g[10], h[10], i[10], j[10], k[10], l[10]; + +void +foo (void) +{ + __atomic_load (c, d, __ATOMIC_ACQUIRE); + __atomic_store (e, f, __ATOMIC_SEQ_CST); + __atomic_exchange (g, h, i, __ATOMIC_RELAXED); + __atomic_compare_exchange (j, k, l, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); +} diff --git a/gcc/testsuite/gcc.dg/pr82112.c b/gcc/testsuite/gcc.dg/pr82112.c new file mode 100644 index 0000000..4ca6919 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr82112.c @@ -0,0 +1,21 @@ +/* PR target/82112 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90" } */ + +struct S { int a[10]; } bar (void); +int b, c; + +void +foo (void) +{ + __atomic_load (bar ().a, &b, __ATOMIC_ACQUIRE); /* { dg-error "argument 1 of .__atomic_load. must be a non-void pointer type" } */ + __atomic_load (&b, bar ().a, __ATOMIC_ACQUIRE); /* { dg-error "argument 2 of .__atomic_load. must be a pointer type" } */ + __atomic_store (bar ().a, &b, __ATOMIC_SEQ_CST); /* { dg-error "argument 1 of .__atomic_store. must be a non-void pointer type" } */ + __atomic_store (&b, bar ().a, __ATOMIC_SEQ_CST); /* { dg-error "argument 2 of .__atomic_store. must be a pointer type" } */ + __atomic_exchange (bar ().a, &b, &c, __ATOMIC_RELAXED); /* { dg-error "argument 1 of .__atomic_exchange. must be a non-void pointer type" } */ + __atomic_exchange (&b, bar ().a, &c, __ATOMIC_RELAXED); /* { dg-error "argument 2 of .__atomic_exchange. must be a pointer type" } */ + __atomic_exchange (&b, &c, bar ().a, __ATOMIC_RELAXED); /* { dg-error "argument 3 of .__atomic_exchange. must be a pointer type" } */ + __atomic_compare_exchange (bar ().a, &b, &c, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); /* { dg-error "argument 1 of .__atomic_compare_exchange. must be a non-void pointer type" } */ + __atomic_compare_exchange (&b, bar ().a, &c, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); /* { dg-error "argument 2 of .__atomic_compare_exchange. must be a pointer type" } */ + __atomic_compare_exchange (&b, &c, bar ().a, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); /* { dg-error "argument 3 of .__atomic_compare_exchange. must be a pointer type" } */ +} |