Skip to content

Commit 1dbc8ef

Browse files
authored
[clang][ptrauth] Make ptrauth feature detection tests more robust (#136204)
The existing test behavior checked for a warning being emitted under an #if, but if the feature detection fails the #if fails and the warning is not expected in the output. I've made the test more explicit, and added comments to ensure no one simply adds/moves any expected output around.
1 parent 0f5c66c commit 1dbc8ef

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

clang/test/Sema/ptrauth-qualifier.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// RUN: %clang_cc1 -triple arm64-apple-ios -std=c23 -fsyntax-only -verify -fptrauth-intrinsics %s
22
// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c23 -fsyntax-only -verify -fptrauth-intrinsics %s
33

4-
#if __has_feature(ptrauth_qualifier)
5-
#warning __ptrauth qualifier enabled!
6-
// expected-warning@-1 {{__ptrauth qualifier enabled!}}
4+
#if !__has_extension(ptrauth_qualifier)
5+
// This error means that the __ptrauth qualifier availability test says that it
6+
// is not available. This error is not expected in the output, if it is seen
7+
// there is a feature detection regression.
8+
#error __ptrauth qualifier not enabled
79
#endif
810

911
#if __aarch64__

clang/test/Sema/ptrauth.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify -fptrauth-intrinsics %s -fexperimental-new-constant-interpreter
22

3-
#if __has_feature(ptrauth_intrinsics)
4-
#warning Pointer authentication enabled!
5-
// expected-warning@-1 {{Pointer authentication enabled!}}
3+
#if !__has_feature(ptrauth_intrinsics)
4+
// This error means that the __ptrauth intrinsics availability test says that
5+
// they are not available. This error is not expected in the output of this
6+
// test, if it is seen there is a feature detection regression.
7+
#error __ptrauth intrinsics not enabled
68
#endif
79

810
#if __aarch64__

clang/test/SemaObjC/ptrauth-qualifier.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify -fptrauth-intrinsics %s
22
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify -fptrauth-intrinsics %s
33

4-
#if __has_feature(ptrauth_qualifier)
5-
#warning __ptrauth qualifier enabled!
6-
// expected-warning@-1 {{__ptrauth qualifier enabled!}}
4+
#if !__has_extension(ptrauth_qualifier)
5+
// This error means that the __ptrauth qualifier availability test says that it
6+
// is not available. This error is not expected in the output, if it is seen
7+
// there is a feature detection regression.
8+
#error __ptrauth qualifier not enabled
79
#endif
810

911
@interface Foo

0 commit comments

Comments
 (0)