aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/c-family/ChangeLog6
-rw-r--r--gcc/c-family/c-common.c14
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr71514.c23
4 files changed, 48 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index ada2be0..cc82370 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2016-08-18 Marek Polacek <polacek@redhat.com>
+
+ PR c/71514
+ * c-common.c (get_atomic_generic_size): Disallow pointer-to-function
+ and pointer-to-VLA.
+
2016-08-16 David Malcolm <dmalcolm@redhat.com>
PR c/72857
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index d413146..22e3844 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -11081,6 +11081,20 @@ get_atomic_generic_size (location_t loc, tree function,
function);
return 0;
}
+ else if (TYPE_SIZE_UNIT (TREE_TYPE (type))
+ && TREE_CODE ((TYPE_SIZE_UNIT (TREE_TYPE (type))))
+ != INTEGER_CST)
+ {
+ error_at (loc, "argument %d of %qE must be a pointer to a constant "
+ "size type", x + 1, function);
+ return 0;
+ }
+ else if (FUNCTION_POINTER_TYPE_P (type))
+ {
+ error_at (loc, "argument %d of %qE must not be a pointer to a "
+ "function", x + 1, function);
+ return 0;
+ }
tree type_size = TYPE_SIZE_UNIT (TREE_TYPE (type));
size = type_size ? tree_to_uhwi (type_size) : 0;
if (size != size_0)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c35808f..e37bff4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-18 Marek Polacek <polacek@redhat.com>
+
+ PR c/71514
+ * gcc.dg/pr71514.c: New test.
+
2015-08-18 H.J. Lu <hongjiu.lu@intel.com>
PR target/72839
diff --git a/gcc/testsuite/gcc.dg/pr71514.c b/gcc/testsuite/gcc.dg/pr71514.c
new file mode 100644
index 0000000..8bfa805
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr71514.c
@@ -0,0 +1,23 @@
+/* PR c/71514 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+foo ()
+{
+}
+
+int a, b;
+
+void
+fn1 (void)
+{
+ __atomic_exchange (&a, &foo, &b, __ATOMIC_RELAXED); /* { dg-error "must not be a pointer to a function" } */
+}
+
+void
+fn2 (int n)
+{
+ int arr[n];
+ __atomic_exchange (&a, &arr, &b, __ATOMIC_RELAXED); /* { dg-error "must be a pointer to a constant size type" } */
+}