File tree Expand file tree Collapse file tree 4 files changed +34
-1
lines changed Expand file tree Collapse file tree 4 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,8 @@ C Language Changes in Clang
124
124
125
125
C2x Feature Support
126
126
-------------------
127
+ - Implemented the ``unreachable `` macro in freestanding ``<stddef.h> `` for
128
+ `WG14 N2826 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2826.pdf >`_
127
129
128
130
C++ Language Changes in Clang
129
131
-----------------------------
Original file line number Diff line number Diff line change @@ -103,6 +103,11 @@ using ::std::nullptr_t;
103
103
typedef typeof (nullptr ) nullptr_t;
104
104
#endif /* defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L */
105
105
106
+ #if defined(__need_STDDEF_H_misc) && defined(__STDC_VERSION__) && \
107
+ __STDC_VERSION__ >= 202000L
108
+ #define unreachable () __builtin_unreachable()
109
+ #endif /* defined(__need_STDDEF_H_misc) && >= C23 */
110
+
106
111
#if defined(__need_STDDEF_H_misc)
107
112
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
108
113
(defined(__cplusplus) && __cplusplus >= 201103L )
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -ffreestanding -emit-llvm -o - -std=c2x %s | FileCheck %s
2
+ // RUN: %clang_cc1 -ffreestanding -std=c17 -verify %s
3
+
4
+ /* WG14 N2826: Clang 17
5
+ * Add annotations for unreachable control flow v2
6
+ */
7
+ #include <stddef.h>
8
+
9
+ enum E {
10
+ Zero ,
11
+ One ,
12
+ Two ,
13
+ };
14
+
15
+ int test (enum E e ) {
16
+ switch (e ) {
17
+ case Zero : return 0 ;
18
+ case One : return 1 ;
19
+ case Two : return 2 ;
20
+ }
21
+ unreachable (); // expected-error {{call to undeclared function 'unreachable'}}
22
+ }
23
+
24
+ // CHECK: switch i32 %0, label %[[EPILOG:.+]] [
25
+ // CHECK: [[EPILOG]]:
26
+ // CHECK-NEXT: unreachable
Original file line number Diff line number Diff line change @@ -1028,7 +1028,7 @@ <h2 id="c2x">C2x implementation status</h2>
1028
1028
< tr >
1029
1029
< td > Add annotations for unreachable control flow v2</ td >
1030
1030
< td > < a href ="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2826.pdf "> N2826</ a > </ td >
1031
- < td class ="none " align ="center "> No </ td >
1031
+ < td class ="unreleased " align ="center "> Clang 17 </ td >
1032
1032
</ tr >
1033
1033
< tr >
1034
1034
< td > Unicode Sequences More Than 21 Bits are a Constraint Violation r0</ td >
You can’t perform that action at this time.
0 commit comments