[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu May 16 06:16:44 PDT 2024
================
@@ -0,0 +1,134 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s
+
+#if !__has_attribute(clang_nonblocking)
+#error "the 'nonblocking' attribute is not available"
+#endif
+
+// --- ATTRIBUTE SYNTAX: SUBJECTS ---
+
+int nl_var [[clang::nonblocking]]; // expected-warning {{'nonblocking' only applies to function types; type here is 'int'}}
+struct nl_struct {} [[clang::nonblocking]]; // expected-warning {{attribute 'nonblocking' is ignored, place it after "struct" to apply attribute to type declaration}}
+struct [[clang::nonblocking]] nl_struct2 {}; // expected-error {{'nonblocking' attribute cannot be applied to a declaration}}
----------------
AaronBallman wrote:
Might as well test some positive situations as well:
```
typedef void (*fo)() [[clang::nonblocking]];
void (*why_is_aaron_this_way(int val, void (*func)(int) [[clang::nonblocking]])[[clang::nonblocking]])(int)[[clang::nonblocking]];
```
https://github.com/llvm/llvm-project/pull/84983
More information about the cfe-commits
mailing list