Message ID | 20170704114411.GP23803@redhat.com |
---|---|
State | New |
Headers | show |
On Tue, 4 Jul 2017, Marek Polacek wrote: > This patch fixes an ICE-on-invalid with __atomic_*. We should check > that we're dealing with a complete type before we're accessing its > TYPE_SIZE_UNIT. > > Bootstrapped/regtested on x86_64-linux, ok for trunk? OK.
diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c index f6a9d05..1b6ac8c 100644 --- gcc/c-family/c-common.c +++ gcc/c-family/c-common.c @@ -6485,6 +6485,9 @@ sync_resolve_size (tree function, vec<tree, va_gc> *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 gcc/testsuite/gcc.dg/atomic-pr81231.c gcc/testsuite/gcc.dg/atomic-pr81231.c index e69de29..304e428 100644 --- gcc/testsuite/gcc.dg/atomic-pr81231.c +++ 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" } */ +}