1 // RUN: %clang_cc1 -triple x86_64-windows -fborland-extensions -DBORLAND -fsyntax-only -verify -fblocks %s
2 // RUN: %clang_cc1 -triple x86_64-windows -fms-extensions -fsyntax-only -verify -fblocks %s
4 #define JOIN2(x,y) x ## y
5 #define JOIN(x,y) JOIN2(x,y)
6 #define TEST2(name) JOIN(name,__LINE__)
7 #define TEST TEST2(test)
10 #pragma sysheader begin
12 struct EXCEPTION_INFO
{};
14 unsigned long __exception_code(void);
16 struct EXCEPTION_INFO
* __exception_info(void);
18 int __abnormal_termination(void);
20 #define GetExceptionCode __exception_code
21 #define GetExceptionInformation __exception_info
22 #define AbnormalTermination __abnormal_termination
26 DWORD
FilterExpression(int); // expected-note{{declared here}}
27 DWORD
FilterExceptionInformation(struct EXCEPTION_INFO
*);
29 const char * NotFilterExpression(void);
50 } // expected-error{{expected '__except' or '__finally' block}}
53 __except (FilterExpression()) { // expected-error{{call to undeclared function '__except'; ISO C99 and later do not support implicit function declarations}} \
54 // expected-error{{too few arguments to function call, expected 1, have 0}} \
55 // expected-error{{expected ';' after expression}}
60 __finally
{ } // expected-error{{}}
66 } // TODO: expected expression is an extra error
67 __except( try_scope
? 1 : -1 ) // expected-error{{undeclared identifier 'try_scope'}} expected-error{{expected expression}}
75 // TODO: Why are there two errors?
76 __except( ) { // expected-error{{expected expression}} expected-error{{expected expression}}
84 __except ( FilterExpression(GetExceptionCode()) ) {
91 __except( FilterExpression(__exception_code()) ) {
98 __except( FilterExceptionInformation(__exception_info()) ) {
105 __except(FilterExceptionInformation( GetExceptionInformation() ) ) {
114 __except ( NotFilterExpression() ) { // expected-error{{filter expression has non-integral type 'const char *'}}
120 int function_scope
= 0;
124 __except ( FilterExpression(GetExceptionCode()) ) {
125 (void)function_scope
;
126 (void)try_scope
; // expected-error{{undeclared identifier}}
131 int function_scope
= 0;
136 (void)function_scope
;
137 (void)try_scope
; // expected-error{{undeclared identifier}}
142 int function_scope
= 0;
146 __except( function_scope
? 1 : -1 ) {}
151 (void)__abnormal_termination(); // expected-error{{only allowed in __finally block}}
152 (void)AbnormalTermination(); // expected-error{{only allowed in __finally block}}
155 (void)AbnormalTermination
; // expected-error{{only allowed in __finally block}}
156 (void)__abnormal_termination
; // expected-error{{only allowed in __finally block}}
159 (void)AbnormalTermination
; // expected-error{{only allowed in __finally block}}
160 (void)__abnormal_termination
; // expected-error{{only allowed in __finally block}}
166 AbnormalTermination();
167 __abnormal_termination();
173 (void)__exception_info(); // expected-error{{only allowed in __except filter expression}}
174 (void)GetExceptionInformation(); // expected-error{{only allowed in __except filter expression}}
179 (void)__exception_code
; // expected-error{{builtin functions must be directly called}}
181 (void)__exception_code(); // expected-error{{only allowed in __except block or filter expression}}
182 (void)GetExceptionCode(); // expected-error{{only allowed in __except block or filter expression}}
188 GetExceptionCode(); // valid
189 GetExceptionInformation(); // expected-error{{only allowed in __except filter expression}}
193 void test_seh_leave_stmt(void) {
194 __leave
; // expected-error{{'__leave' statement not in __try block}}
198 __leave
4; // expected-error{{expected ';' after __leave statement}}
200 __leave
; // expected-error{{'__leave' statement not in __try block}}
206 __leave
; // expected-error{{'__leave' statement not in __try block}}
208 __leave
; // expected-error{{'__leave' statement not in __try block}}
211 void test_jump_out_of___finally(void) {
215 continue; // expected-warning{{jump out of __finally block has undefined behavior}}
225 // Check that a deep __finally containing a block with a shallow continue
226 // doesn't trigger the warning.
240 break; // expected-warning{{jump out of __finally block has undefined behavior}}
247 break; // expected-warning{{jump out of __finally block has undefined behavior}}
260 __leave
; // expected-warning{{jump out of __finally block has undefined behavior}}
274 return; // expected-warning{{jump out of __finally block has undefined behavior}}
285 void test_typo_in_except(void) {
287 } __except(undeclared_identifier
) { // expected-error {{use of undeclared identifier 'undeclared_identifier'}} expected-error {{expected expression}}