-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C2x] Implement the
unreachable
macro for WG14 N2826
This exposes __builtin_unreachable as the expansion for the unreachable macro in C2x. I added this definition under __need_STDDEF_H_misc on the assumption there is no need for a separate need macro to control adding this. Differential Revision: https://reviews.llvm.org/D143430
- Loading branch information
1 parent
d6ff080
commit a9797d7
Showing
4 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// RUN: %clang_cc1 -ffreestanding -emit-llvm -o - -std=c2x %s | FileCheck %s | ||
// RUN: %clang_cc1 -ffreestanding -std=c17 -verify %s | ||
|
||
/* WG14 N2826: Clang 17 | ||
* Add annotations for unreachable control flow v2 | ||
*/ | ||
#include <stddef.h> | ||
|
||
enum E { | ||
Zero, | ||
One, | ||
Two, | ||
}; | ||
|
||
int test(enum E e) { | ||
switch (e) { | ||
case Zero: return 0; | ||
case One: return 1; | ||
case Two: return 2; | ||
} | ||
unreachable(); // expected-error {{call to undeclared function 'unreachable'}} | ||
} | ||
|
||
// CHECK: switch i32 %0, label %[[EPILOG:.+]] [ | ||
// CHECK: [[EPILOG]]: | ||
// CHECK-NEXT: unreachable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters