]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c/61553 (__atomic_store with non-pointer arg ICE)
authorMarek Polacek <polacek@redhat.com>
Tue, 20 Jan 2015 14:19:35 +0000 (14:19 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 20 Jan 2015 14:19:35 +0000 (14:19 +0000)
Backport from mainline
2014-06-23  Marek Polacek  <polacek@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.

From-SVN: r219897

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr61553.c [new file with mode: 0644]

index bb4278fe6586cac3d9801c2e1915f320ae398fa0..b230bc4a303e624633e1c4df89a033e138e8899e 100644 (file)
@@ -1,3 +1,12 @@
+2015-01-20  Marek Polacek  <polacek@redhat.com>
+
+       Backport from mainline
+       2014-06-23  Marek Polacek  <polacek@redhat.com>
+
+       PR c/61553
+       * c-common.c (get_atomic_generic_size): Don't segfault if the
+       type doesn't have a size.
+
 2014-12-19  Release Manager
 
        * GCC 4.8.4 released.
index 86f64ec60e80c1a7269da9cdf5589879d2a05223..f41ec9ca88960579ae0525fc869f9f7b26ba0ee1 100644 (file)
@@ -10143,7 +10143,8 @@ get_atomic_generic_size (location_t loc, tree function,
                    function);
          return 0;
        }
-      size = tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (type)), 1);
+      tree type_size = TYPE_SIZE_UNIT (TREE_TYPE (type));
+      size = type_size ? tree_low_cst (type_size, 1) : 0;
       if (size != size_0)
        {
          error_at (loc, "size mismatch in argument %d of %qE", x + 1,
index 30f131ca76fcc8ef70c3c9fe007d896b814fb100..fde23519a363b05569f01f6b516d07ba71dab4c2 100644 (file)
@@ -1,3 +1,11 @@
+2015-01-20  Marek Polacek  <polacek@redhat.com>
+
+       Backport from mainline
+       2014-06-23  Marek Polacek  <polacek@redhat.com>
+
+       PR c/61553
+       * c-c++-common/pr61553.c: New test.
+
 2015-01-12  Janus Weil  <janus@gcc.gnu.org>
 
        Backport from mainline
diff --git a/gcc/testsuite/c-c++-common/pr61553.c b/gcc/testsuite/c-c++-common/pr61553.c
new file mode 100644 (file)
index 0000000..8a3b699
--- /dev/null
@@ -0,0 +1,8 @@
+/* PR c/61553 */
+/* { dg-do compile } */
+
+void
+foo (char *s)
+{
+  __atomic_store (s, (void *) 0, __ATOMIC_SEQ_CST); /* { dg-error "size mismatch" } */
+}