You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recognize setjmp and friends as builtins even if jmp_buf is not declared yet.
This happens in glibc's headers. It's important that we recognize these
functions so that we can mark them as returns_twice.
Differential Revision: https://reviews.llvm.org/D88518
externlongsetjmp(long*); // expected-warning {{declaration of built-in function 'setjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header <setjmp.h>.}}
6
-
#else
8
+
// This happens in some versions of glibc: the declaration of __sigsetjmp
9
+
// precedes the declaration of sigjmp_buf.
10
+
externlongsetjmp(long*); // Can't check, so we trust that this is the right type
11
+
// FIXME: We could still diagnose the missing `jmp_buf` at the point of the call.
12
+
// expected-no-diagnostics
13
+
#elifWRONG_JMP_BUF
7
14
typedeflongjmp_buf;
8
-
externintsetjmp(char); // expected-warning@8 {{incompatible redeclaration of library function 'setjmp'}}
9
-
// expected-note@8 {{'setjmp' is a builtin with type 'int (jmp_buf)' (aka 'int (long)')}}
15
+
externintsetjmp(char); // expected-warning {{incompatible redeclaration of library function 'setjmp'}}
16
+
// expected-note@-1 {{'setjmp' is a builtin with type 'int (jmp_buf)' (aka 'int (long)')}}
17
+
#elifRIGHT_JMP_BUF
18
+
typedeflongjmp_buf;
19
+
externintsetjmp(long); // OK, right type.
20
+
// expected-no-diagnostics
21
+
#elifONLY_JMP_BUF
22
+
typedefint*jmp_buf;
10
23
#endif
24
+
25
+
voiduse() {
26
+
setjmp(0);
27
+
#ifdefNO_SETJMP
28
+
// expected-warning@-2 {{implicit declaration of function 'setjmp' is invalid in C99}}
29
+
#elifONLY_JMP_BUF
30
+
// expected-warning@-4 {{implicitly declaring library function 'setjmp' with type 'int (jmp_buf)' (aka 'int (int *)')}}
31
+
// expected-note@-5 {{include the header <setjmp.h> or explicitly provide a declaration for 'setjmp'}}
32
+
#endif
33
+
34
+
#ifdefNO_SETJMP
35
+
// In this case, the regular AST dump doesn't dump the implicit declaration of 'setjmp'.
Copy file name to clipboardExpand all lines: clang/test/Sema/implicit-builtin-decl.c
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -54,13 +54,12 @@ main(int argc, char *argv[])
54
54
55
55
voidsnprintf() { }
56
56
57
-
// PR8316 & PR40692
58
-
voidlongjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header <setjmp.h>.}}
57
+
voidlongjmp();
59
58
60
59
externfloatfmaxf(float, float);
61
60
62
61
struct__jmp_buf_tag {};
63
-
voidsigsetjmp(struct__jmp_buf_tag[1], int);// expected-warning{{declaration of built-in function 'sigsetjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header <setjmp.h>.}}
0 commit comments