Debian Codegraph @

clang/test/Sema/attr-nonblocking-constraints.c

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -Wfunction-effects -internal-isystem %S/../Headers/Inputs/include %s
2
3 // Tests for a few cases involving C functions without prototypes.
4
5 void hasproto(void) __attribute__((blocking)); // expected-note {{function does not permit inference of 'nonblocking' because it is declared 'blocking'}}
6
7 // Has no prototype, inferably safe.
8 void nb1() {}
9
10 // Has no prototype, noreturn.
11 [[noreturn]]
12 void aborts();
13
14 void nb2(void) __attribute__((nonblocking)) {
15 hasproto(); // expected-warning {{function with 'nonblocking' attribute must not call non-'nonblocking' function 'hasproto'}}
16 nb1();
17 aborts(); // no diagnostic because it's noreturn.
18 }
19
20 #include <setjmp.h>
21
22 void nb3(int x, int y) __attribute__((nonblocking)) {
23 if (x != y) {
24 jmp_buf jb;
25 longjmp(jb, 0); // expected-warning {{function with 'nonblocking' attribute must not call non-'nonblocking' function 'longjmp'}}
26 }
27 }