re PR c/81231 (ICE with invalid argument to __atomic_*)
authorMarek Polacek <polacek@redhat.com>
Tue, 4 Jul 2017 12:17:22 +0000 (12:17 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 4 Jul 2017 12:17:22 +0000 (12:17 +0000)
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
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/atomic-pr81231.c [new file with mode: 0644]

index 5f32102128c6c63fba624b323c2e629933626445..a54beee37f99adb38590ad06f560716c14bf6721 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-04  Marek Polacek  <polacek@redhat.com>
+
+       PR c/81231
+       * c-common.c (sync_resolve_size): Give error for pointers to incomplete
+       types.
+
 2017-07-04  Marek Polacek  <polacek@redhat.com>
 
        * c-warn.c (warn_if_unused_value): Remove WITH_CLEANUP_EXPR handling.
index f6a9d05c3da2ec9de6b4730a55d838f98e31a6df..1b6ac8cffa26dfea304035ec938a981fb8810c9d 100644 (file)
@@ -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;
 
index 74f9ee6ab97f733ca5b969acb571c17f55d12889..93926b28454bd3495fa701b93a3ebad79de3719e 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-04  Marek Polacek  <polacek@redhat.com>
+
+       PR c/81231
+       * gcc.dg/atomic-pr81231.c: New test.
+
 2017-07-04  Richard Sandiford  <richard.sandiford@linaro.org>
 
        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 (file)
index 0000000..304e428
--- /dev/null
@@ -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" } */
+}