llvm-project/clang/test/Sema/attr-nonblocking-sema.c
Doug Wyatt f03cb005eb
[Clang] Introduce nonblocking/nonallocating attributes (#84983)
Introduce `nonblocking` and `nonallocating` attributes. RFC is here:
https://discourse.llvm.org/t/rfc-nolock-and-noalloc-attributes/76837

This PR introduces the attributes, with some changes in Sema to deal
with them as extensions to function (proto)types.

There are some basic type checks, most importantly, a warning when
trying to spoof the attribute (implicitly convert a function without the
attribute to one that has it).

A second, follow-on pull request will introduce new caller/callee
verification.
---------
Co-authored-by: Doug Wyatt <dwyatt@apple.com>
Co-authored-by: Shafik Yaghmour <shafik.yaghmour@intel.com>
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
Co-authored-by: Sirraide <aeternalmail@gmail.com>
2024-06-24 12:51:31 +02:00

15 lines
494 B
C

// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 %s
// Tests for a few cases involving C functions without prototypes.
void noproto() __attribute__((nonblocking)) // expected-error {{'nonblocking' function must have a prototype}}
{
}
// This will succeed
void noproto(void) __attribute__((blocking));
// A redeclaration isn't any different - a prototype is required.
void f1(void);
void f1() __attribute__((nonblocking)); // expected-error {{'nonblocking' function must have a prototype}}