We ICEd on the following testcase since the void type has a NULL
TYPE_SIZE_UNIT.  I took Andrew's patch from gcc@ ML and added
a testcase.

Regtested/bootstrapped on x86_64-linux, ok for trunk?

2014-06-23  Marek Polacek  <pola...@redhat.com>
            Andrew MacLeod  <amacl...@redhat.com>

        PR c/61553
        * c-common.c (get_atomic_generic_size): Don't segfault if the
        type doesn't have a size.

        * c-c++-common/pr61553.c: New test.

diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index 077263e..087f036 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -10471,7 +10471,8 @@ get_atomic_generic_size (location_t loc, tree function,
                    function);
          return 0;
        }
-      size = tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (type)));
+      tree type_size = TYPE_SIZE_UNIT (TREE_TYPE (type));
+      size = type_size ? tree_to_uhwi (type_size) : 0;
       if (size != size_0)
        {
          error_at (loc, "size mismatch in argument %d of %qE", x + 1,
diff --git gcc/testsuite/c-c++-common/pr61553.c 
gcc/testsuite/c-c++-common/pr61553.c
index e69de29..fa97e94 100644
--- gcc/testsuite/c-c++-common/pr61553.c
+++ gcc/testsuite/c-c++-common/pr61553.c
@@ -0,0 +1,8 @@
+/* PR c/61553 */
+/* { dg-do compile } */
+
+void
+foo (char *s)
+{
+  __atomic_store (s, (void *) 0, __ATOMIC_SEQ_CST);
+}

        Marek

Reply via email to