brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.2 KiB · a93787c Raw
74 lines · c
1// RUN: %clang_cc1 -fgnuc-version=4.2.1 -triple=i686-linux-gnu -ffreestanding -fexperimental-new-constant-interpreter -verify=both,expected %s2// RUN: %clang_cc1 -fgnuc-version=4.2.1 -triple=i686-linux-gnu -ffreestanding -verify=both,ref %s3 4/// FIXME: Copied from test/Sema/atomic-expr.c.5/// this expression seems to be rejected for weird reasons,6/// but we imitate the current interpreter's behavior.7_Atomic int ai = 0;8// FIXME: &ai is an address constant, so this should be accepted as an9// initializer, but the bit-cast inserted due to the pointer conversion is10// tripping up the test for whether the initializer is a constant expression.11// The first error is correct; the second is not.12_Atomic(int *) aip3 = &ai; // both-error {{incompatible pointer types initializing '_Atomic(int *)' with an expression of type '_Atomic(int) *'}} \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), "");61 62_Static_assert(__atomic_always_lock_free(1, (void*)1), "");63_Static_assert(__atomic_always_lock_free(1, (void*)-1), "");64_Static_assert(!__atomic_always_lock_free(4, (void*)2), "");65_Static_assert(!__atomic_always_lock_free(4, (void*)-2), "");66_Static_assert(__atomic_always_lock_free(4, (void*)4), "");67_Static_assert(__atomic_always_lock_free(4, (void*)-4), "");68 69_Static_assert(__atomic_always_lock_free(1, "string"), "");70_Static_assert(!__atomic_always_lock_free(2, "string"), "");71_Static_assert(__atomic_always_lock_free(2, (int[2]){}), "");72void dummyfn();73_Static_assert(__atomic_always_lock_free(2, dummyfn) || 1, "");74