1
- // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=both,expected %s
2
- // RUN: %clang_cc1 -verify=both,ref %s
1
+ // RUN: %clang_cc1 -fgnuc-version=4.2.1 - fexperimental-new-constant-interpreter -verify=both,expected %s
2
+ // RUN: %clang_cc1 -fgnuc-version=4.2.1 - verify=both,ref %s
3
3
4
4
/// FIXME: Copied from test/Sema/atomic-expr.c.
5
5
/// this expression seems to be rejected for weird reasons,
@@ -11,3 +11,50 @@ _Atomic int ai = 0;
11
11
// The warning is correct but the error is not.
12
12
_Atomic(int * ) aip3 = & ai ; // both-warning {{incompatible pointer types initializing '_Atomic(int *)' with an expression of type '_Atomic(int) *'}} \
13
13
// both-error {{initializer element is not a compile-time constant}}
14
+
15
+ #include <stdatomic.h>
16
+
17
+
18
+
19
+ _Static_assert (__GCC_ATOMIC_BOOL_LOCK_FREE == 2 , "" );
20
+ _Static_assert (__GCC_ATOMIC_BOOL_LOCK_FREE == __CLANG_ATOMIC_BOOL_LOCK_FREE , "" );
21
+ _Static_assert (__GCC_ATOMIC_CHAR_LOCK_FREE == 2 , "" );
22
+ _Static_assert (__GCC_ATOMIC_CHAR_LOCK_FREE == __CLANG_ATOMIC_CHAR_LOCK_FREE , "" );
23
+ _Static_assert (__GCC_ATOMIC_CHAR16_T_LOCK_FREE == 2 , "" );
24
+ _Static_assert (__GCC_ATOMIC_CHAR16_T_LOCK_FREE == __CLANG_ATOMIC_CHAR16_T_LOCK_FREE , "" );
25
+ _Static_assert (__GCC_ATOMIC_CHAR32_T_LOCK_FREE == 2 , "" );
26
+ _Static_assert (__GCC_ATOMIC_CHAR32_T_LOCK_FREE == __CLANG_ATOMIC_CHAR32_T_LOCK_FREE , "" );
27
+ _Static_assert (__GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2 , "" );
28
+ _Static_assert (__GCC_ATOMIC_WCHAR_T_LOCK_FREE == __CLANG_ATOMIC_WCHAR_T_LOCK_FREE , "" );
29
+ _Static_assert (__GCC_ATOMIC_SHORT_LOCK_FREE == 2 , "" );
30
+ _Static_assert (__GCC_ATOMIC_SHORT_LOCK_FREE == __CLANG_ATOMIC_SHORT_LOCK_FREE , "" );
31
+ _Static_assert (__GCC_ATOMIC_INT_LOCK_FREE == 2 , "" );
32
+ _Static_assert (__GCC_ATOMIC_INT_LOCK_FREE == __CLANG_ATOMIC_INT_LOCK_FREE , "" );
33
+ _Static_assert (__GCC_ATOMIC_LONG_LOCK_FREE == 2 , "" );
34
+ _Static_assert (__GCC_ATOMIC_LONG_LOCK_FREE == __CLANG_ATOMIC_LONG_LOCK_FREE , "" );
35
+ _Static_assert (__GCC_ATOMIC_LLONG_LOCK_FREE == 2 , "" );
36
+ _Static_assert (__GCC_ATOMIC_LLONG_LOCK_FREE == __CLANG_ATOMIC_LLONG_LOCK_FREE , "" );
37
+ _Static_assert (__GCC_ATOMIC_POINTER_LOCK_FREE == 2 , "" );
38
+ _Static_assert (__GCC_ATOMIC_POINTER_LOCK_FREE == __CLANG_ATOMIC_POINTER_LOCK_FREE , "" );
39
+
40
+ _Static_assert (__c11_atomic_is_lock_free (1 ), "" );
41
+ _Static_assert (__c11_atomic_is_lock_free (2 ), "" );
42
+ _Static_assert (__c11_atomic_is_lock_free (3 ), "" ); // both-error {{not an integral constant expression}}
43
+ _Static_assert (__c11_atomic_is_lock_free (4 ), "" );
44
+ _Static_assert (__c11_atomic_is_lock_free (8 ), "" );
45
+ _Static_assert (__c11_atomic_is_lock_free (16 ), "" ); // both-error {{not an integral constant expression}}
46
+ _Static_assert (__c11_atomic_is_lock_free (17 ), "" ); // both-error {{not an integral constant expression}}
47
+
48
+ _Static_assert (__atomic_is_lock_free (1 , 0 ), "" );
49
+ _Static_assert (__atomic_is_lock_free (2 , 0 ), "" );
50
+ _Static_assert (__atomic_is_lock_free (3 , 0 ), "" ); // both-error {{not an integral constant expression}}
51
+ _Static_assert (__atomic_is_lock_free (4 , 0 ), "" );
52
+ _Static_assert (__atomic_is_lock_free (8 , 0 ), "" );
53
+ _Static_assert (__atomic_is_lock_free (16 , 0 ), "" ); // both-error {{not an integral constant expression}}
54
+ _Static_assert (__atomic_is_lock_free (17 , 0 ), "" ); // both-error {{not an integral constant expression}}
55
+
56
+ _Static_assert (atomic_is_lock_free ((atomic_char * )0 ), "" );
57
+ _Static_assert (atomic_is_lock_free ((atomic_short * )0 ), "" );
58
+ _Static_assert (atomic_is_lock_free ((atomic_int * )0 ), "" );
59
+ _Static_assert (atomic_is_lock_free ((atomic_long * )0 ), "" );
60
+ _Static_assert (atomic_is_lock_free (0 + (atomic_char * )0 ), "" );
0 commit comments