+2016-09-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/77624
+ * builtins.c (fold_builtin_atomic_always_lock_free): Only look through
+ cast to void * if the cast is from some other pointer type.
+
2016-09-20 Richard Biener <rguenther@suse.de>
PR tree-optimization/77646
end before anything else has a chance to look at it. The pointer
parameter at this point is usually cast to a void *, so check for that
and look past the cast. */
- if (CONVERT_EXPR_P (arg1) && POINTER_TYPE_P (ttype)
- && VOID_TYPE_P (TREE_TYPE (ttype)))
+ if (CONVERT_EXPR_P (arg1)
+ && POINTER_TYPE_P (ttype)
+ && VOID_TYPE_P (TREE_TYPE (ttype))
+ && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (arg1, 0))))
arg1 = TREE_OPERAND (arg1, 0);
ttype = TREE_TYPE (arg1);
+2016-09-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/77624
+ * c-c++-common/pr77624-1.c: New test.
+ * c-c++-common/pr77624-2.c: New test.
+
2016-09-20 Andre Vehreschild <vehre@gcc.gnu.org>
* gfortran.dg/coarray_allocate_7.f08: Using + instead of fixed number
--- /dev/null
+/* PR middle-end/77624 */
+/* { dg-do compile } */
+
+int
+foo (int a)
+{
+ return __atomic_is_lock_free (2, a); /* { dg-warning "pointer from integer" "" { target c } } */
+} /* { dg-error "invalid conversion" "" { target c++ } 7 } */
+
+int
+bar (int a)
+{
+ return __atomic_always_lock_free (2, a); /* { dg-warning "pointer from integer" "" { target c } } */
+} /* { dg-error "invalid conversion" "" { target c++ } 13 } */
--- /dev/null
+/* PR middle-end/77624 */
+/* { dg-do compile } */
+
+void
+foo (int *a)
+{
+ double b = 0;
+ __atomic_is_lock_free (2, a, 2); /* { dg-error "too many arguments" } */
+ __atomic_is_lock_free (2); /* { dg-error "too few arguments" } */
+ __atomic_is_lock_free (2, b); /* { dg-error "incompatible type" "" { target c } } */
+ /* { dg-message "expected" "" { target c } 10 } */
+ /* { dg-error "convert" "" { target c++ } 10 } */
+ __atomic_is_lock_free (2, 0);
+}
+
+void
+bar (int *a)
+{
+ double b = 0;
+ __atomic_always_lock_free (2, a, 2); /* { dg-error "too many arguments" } */
+ __atomic_always_lock_free (2); /* { dg-error "too few arguments" } */
+ __atomic_always_lock_free (2, b); /* { dg-error "incompatible type" "" { target c } } */
+ /* { dg-message "expected" "" { target c } 22 } */
+ /* { dg-error "convert" "" { target c++ } 22 } */
+ __atomic_always_lock_free (2, 0);
+}