From efbf55b01cc45b0550830e0008db9ea6bae22f5e Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Tue, 4 Jul 2017 12:17:22 +0000 Subject: [PATCH] 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 --- gcc/c-family/ChangeLog | 6 ++++++ gcc/c-family/c-common.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/atomic-pr81231.c | 12 ++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/atomic-pr81231.c 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" } */ +} -- 2.30.2