1
- // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DNO_JMP_BUF %s -ast-dump | FileCheck %s
2
- // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DWRONG_JMP_BUF %s -ast-dump | FileCheck %s
3
- // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s
4
- // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DONLY_JMP_BUF %s -ast-dump | FileCheck %s
5
- // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DNO_SETJMP %s -ast-dump 2>&1 | FileCheck %s
1
+ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=c,expected -DNO_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
2
+ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=c,expected -DWRONG_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
3
+ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=c,expected -DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
4
+ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=c,expected -DONLY_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
5
+ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=c,expected -DNO_SETJMP %s -ast-dump 2>&1 | FileCheck %s --check-prefixes=CHECK1,CHECK2
6
+ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=cxx,expected -x c++ -DNO_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
7
+ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=cxx,expected -x c++ -DWRONG_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
8
+ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=cxx,expected -x c++ -DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
9
+ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=cxx,expected -x c++ -DONLY_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK2
10
+ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=cxx,expected -x c++ -DNO_SETJMP %s -ast-dump | FileCheck %s --check-prefixes=CHECK2
11
+
12
+ #ifdef __cplusplus
13
+ extern "C" {
14
+ #endif
6
15
7
16
#ifdef NO_JMP_BUF
8
17
// This happens in some versions of glibc: the declaration of __sigsetjmp
9
18
// precedes the declaration of sigjmp_buf.
10
19
extern long setjmp (long * ); // Can't check, so we trust that this is the right type
11
20
// FIXME: We could still diagnose the missing `jmp_buf` at the point of the call.
12
- // expected -no-diagnostics
21
+ // c -no-diagnostics
13
22
#elif WRONG_JMP_BUF
14
23
typedef long jmp_buf ;
15
- extern int setjmp (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)')}}
24
+ // FIXME: Consider producing a similar warning in C++.
25
+ extern int setjmp (char ); // c-warning {{incompatible redeclaration of library function 'setjmp'}}
26
+ // c-note@-1 {{'setjmp' is a builtin with type 'int (jmp_buf)' (aka 'int (long)')}}
17
27
#elif RIGHT_JMP_BUF
18
28
typedef long jmp_buf ;
19
29
extern int setjmp (long ); // OK, right type.
20
- // expected-no-diagnostics
21
30
#elif ONLY_JMP_BUF
22
31
typedef int * jmp_buf ;
23
32
#endif
24
33
25
34
void use () {
26
35
setjmp (0 );
27
- #ifdef NO_SETJMP
28
- // expected-warning@-2 {{implicit declaration of function 'setjmp' is invalid in C99}}
36
+ #if NO_SETJMP
37
+ // cxx-error@-2 {{undeclared identifier 'setjmp'}}
38
+ // c-warning@-3 {{implicit declaration of function 'setjmp' is invalid in C99}}
29
39
#elif ONLY_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'}}
40
+ // cxx-error@-5 {{undeclared identifier 'setjmp'}}
41
+ // c-warning@-6 {{implicitly declaring library function 'setjmp' with type 'int (jmp_buf)' (aka 'int (int *)')}}
42
+ // c-note@-7 {{include the header <setjmp.h> or explicitly provide a declaration for 'setjmp'}}
43
+ #else
44
+ // cxx-no-diagnostics
32
45
#endif
33
46
34
47
#ifdef NO_SETJMP
@@ -37,6 +50,24 @@ void use() {
37
50
#endif
38
51
}
39
52
40
- // CHECK: FunctionDecl {{.*}} used setjmp
41
- // CHECK: BuiltinAttr {{.*}} Implicit
42
- // CHECK: ReturnsTwiceAttr {{.*}} Implicit
53
+ // CHECK1: FunctionDecl {{.*}} used setjmp
54
+ // CHECK1: BuiltinAttr {{.*}} Implicit
55
+ // CHECK1: ReturnsTwiceAttr {{.*}} Implicit
56
+
57
+ // mingw declares _setjmp with an unusual signature.
58
+ int _setjmp (void * , void * );
59
+ #if !defined(NO_JMP_BUF ) && !defined(NO_SETJMP )
60
+ // c-warning@-2 {{incompatible redeclaration of library function '_setjmp'}}
61
+ // c-note@-3 {{'_setjmp' is a builtin with type 'int (jmp_buf)'}}
62
+ #endif
63
+ void use_mingw () {
64
+ _setjmp (0 , 0 );
65
+ }
66
+
67
+ // CHECK2: FunctionDecl {{.*}} used _setjmp
68
+ // CHECK2: BuiltinAttr {{.*}} Implicit
69
+ // CHECK2: ReturnsTwiceAttr {{.*}} Implicit
70
+
71
+ #ifdef __cplusplus
72
+ }
73
+ #endif
0 commit comments