1 // RUN: %clang_cc1 -std=c++03 -fblocks -triple x86_64-windows-msvc -fms-extensions -fsyntax-only -fexceptions -fcxx-exceptions -verify %s
2 // RUN: %clang_cc1 -std=c++11 -fblocks -triple x86_64-windows-msvc -fms-extensions -fsyntax-only -fexceptions -fcxx-exceptions -verify %s
4 // Basic usage should work.
5 int safe_div(int n
, int d
) {
9 } __except(_exception_code() == 0xC0000094) {
17 // Diagnose obvious builtin mis-usage.
18 void bad_builtin_scope() {
23 _exception_code(); // expected-error {{'_exception_code' only allowed in __except block or filter expression}}
24 _exception_info(); // expected-error {{'_exception_info' only allowed in __except filter expression}}
27 // Diagnose obvious builtin misusage in a template.
29 void bad_builtin_scope_template() {
34 _exception_code(); // expected-error {{'_exception_code' only allowed in __except block or filter expression}}
35 _exception_info(); // expected-error {{'_exception_info' only allowed in __except filter expression}}
37 void instantiate_bad_scope_tmpl() {
38 bad_builtin_scope_template
<might_crash
>();
41 #if __cplusplus < 201103L
42 template <typename T
, T
FN()>
44 return FN(); // expected-error 2{{builtin functions must be directly called}}
46 void inject_builtins() {
47 func_template
<void *, __exception_info
>(); // expected-note {{instantiation of}}
48 func_template
<unsigned long, __exception_code
>(); // expected-note {{instantiation of}}
52 void use_seh_after_cxx() {
53 try { // expected-note {{conflicting 'try' here}}
57 __try
{ // expected-error {{cannot use C++ 'try' in the same function as SEH '__try'}}
63 void use_cxx_after_seh() {
64 __try
{ // expected-note {{conflicting '__try' here}}
68 try { // expected-error {{cannot use C++ 'try' in the same function as SEH '__try'}}
74 #if __cplusplus >= 201103L
75 void use_seh_in_lambda() {
89 void use_seh_in_block() {
91 __try
{ // expected-error {{cannot use SEH '__try' in blocks, captured regions, or Obj-C method decls}}
102 void (^use_seh_in_global_block
)() = ^{
103 __try
{ // expected-error {{cannot use SEH '__try' in blocks, captured regions, or Obj-C method decls}}
109 void (^use_cxx_in_global_block
)() = ^{
116 template <class T
> void dependent_filter() {
119 } __except (T()) { // expected-error {{filter expression has non-integral type 'NotInteger'}}
123 struct NotInteger
{ int x
; };
125 void instantiate_dependent_filter() {
126 dependent_filter
<int>();
127 dependent_filter
<NotInteger
>(); // expected-note {{requested here}}