From: Marek Polacek Date: Tue, 4 Jul 2017 12:17:22 +0000 (+0000) Subject: re PR c/81231 (ICE with invalid argument to __atomic_*) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=efbf55b01cc45b0550830e0008db9ea6bae22f5e;p=gcc.git re PR c/81231 (ICE with invalid argument to __atomic_*) PR c/81231 * c-common.c (sync_resolve_size): Give error for pointers to incomplete types. * gcc.dg/atomic-pr81231.c: New test. From-SVN: r249963 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 5f32102128c..a54beee37f9 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2017-07-04 Marek Polacek + + PR c/81231 + * c-common.c (sync_resolve_size): Give error for pointers to incomplete + types. + 2017-07-04 Marek Polacek * c-warn.c (warn_if_unused_value): Remove WITH_CLEANUP_EXPR handling. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index f6a9d05c3da..1b6ac8cffa2 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -6485,6 +6485,9 @@ sync_resolve_size (tree function, vec *params, bool fetch) if (!INTEGRAL_TYPE_P (type) && !POINTER_TYPE_P (type)) goto incompatible; + if (!COMPLETE_TYPE_P (type)) + goto incompatible; + if (fetch && TREE_CODE (type) == BOOLEAN_TYPE) goto incompatible; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 74f9ee6ab97..93926b28454 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-04 Marek Polacek + + PR c/81231 + * gcc.dg/atomic-pr81231.c: New test. + 2017-07-04 Richard Sandiford PR tree-optimization/81292 diff --git a/gcc/testsuite/gcc.dg/atomic-pr81231.c b/gcc/testsuite/gcc.dg/atomic-pr81231.c new file mode 100644 index 00000000000..304e4281f7b --- /dev/null +++ b/gcc/testsuite/gcc.dg/atomic-pr81231.c @@ -0,0 +1,12 @@ +/* PR c/81231 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +enum E; + +void +foo (void) +{ + __atomic_load_n ((enum E *) 0, 0); /* { dg-error "incompatible" } */ + __atomic_load_n ((enum X *) 0, 0); /* { dg-error "incompatible" } */ +}