File: n2934.c

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (58 lines) | stat: -rw-r--r-- 2,694 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// RUN: %clang_cc1 -ffreestanding -verify=c2x -std=c2x -Wpre-c2x-compat %s
// RUN: %clang_cc1 -ffreestanding -verify=c17 -std=c17 %s

/* WG14 N2934: yes
 * Revise spelling of keywords v7
 */

thread_local struct alignas(int) S { // c2x-warning {{'alignas' is incompatible with C standards before C2x}} \
                                        c2x-warning {{'thread_local' is incompatible with C standards before C2x}} \
                                        c2x-error 0+ {{thread-local storage is not supported for the current target}} \
                                        c17-error {{unknown type name 'thread_local'}} \
                                        c17-error {{expected identifier or '('}} \
                                        c17-error {{expected ')'}} \
                                        c17-note {{to match this '('}}
  bool b; // c2x-warning {{'bool' is incompatible with C standards before C2x}}
} s; // c17-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}

static_assert(alignof(struct S) == alignof(int), ""); // c2x-warning {{'static_assert' is incompatible with C standards before C2x}} \
                                                         c2x-warning 2 {{'alignof' is incompatible with C standards before C2x}} \
                                                         c17-error 2 {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} \
                                                         c17-error {{expected ')'}} \
                                                         c17-warning {{declaration of 'struct S' will not be visible outside of this function}} \
                                                         c17-note {{to match this '('}}

#include <stdalign.h>

// C17 and earlier must have __alignas_is_defined and __alignof_is_defined,
// but C2x and later must not.
#if __STDC_VERSION__ <= 201710L
  #if __alignas_is_defined != 1
    #error "alignas should be defined"
  #endif
  #if __alignof_is_defined != 1
    #error "alignof should be defined"
  #endif
#else
  #ifdef __alignas_is_defined
    #error "alignas should not be defined"
  #endif
  #ifdef __alignof_is_defined
    #error "alignof should not be defined"
  #endif
#endif

#include <stdbool.h>

// C17 and earlier must have bool defined as a macro, but C2x and later should
// not (at least in Clang's implementation; it's permissible for bool to be a
// macro in general, as it could expand to _Bool).
#if __STDC_VERSION__ <= 201710L
  #ifndef bool
    #error "bool should be defined"
  #endif
#else
  #ifdef bool
    #error "bool should not be defined"
  #endif
#endif