1 // RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify -triple i686-pc-win32 %s
2 // RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify -triple x86_64-pc-win32 %s
3 // RUN: %clang_cc1 -x c++ -fsyntax-only -fms-extensions -verify -triple i686-pc-win32 %s
4 // RUN: %clang_cc1 -x c++ -DEXTERN_C='extern "C"' -fsyntax-only -fms-extensions -verify -triple i686-pc-win32 %s
5 
6 #ifndef EXTERN_C
7 #define EXTERN_C
8 #if defined(__cplusplus)
9 #define EXPECT_NODIAG
10 // expected-no-diagnostics
11 #endif
12 #endif
13 
14 #ifndef EXPECT_NODIAG
15 // expected-note-re@+2 1+ {{forward declaration of '{{(struct )?}}Foo'}}
16 #endif
17 struct Foo;
18 
19 EXTERN_C void __stdcall fwd_std(struct Foo p);
20 #if !defined(EXPECT_NODIAG) && defined(_M_IX86)
21 // expected-error@+2 {{parameter 'p' must have a complete type to use function 'fwd_std' with the stdcall calling convention}}
22 #endif
23 void (__stdcall *fp_fwd_std)(struct Foo) = &fwd_std;
24 
25 EXTERN_C void __fastcall fwd_fast(struct Foo p);
26 #if !defined(EXPECT_NODIAG) && defined(_M_IX86)
27 // expected-error@+2 {{parameter 'p' must have a complete type to use function 'fwd_fast' with the fastcall calling convention}}
28 #endif
29 void (__fastcall *fp_fwd_fast)(struct Foo) = &fwd_fast;
30 
31 EXTERN_C void __vectorcall fwd_vector(struct Foo p);
32 #if !defined(EXPECT_NODIAG)
33 // expected-error@+2 {{parameter 'p' must have a complete type to use function 'fwd_vector' with the vectorcall calling convention}}
34 #endif
35 void (__vectorcall *fp_fwd_vector)(struct Foo) = &fwd_vector;
36 
37 #if defined(__cplusplus)
38 template <typename T> struct TemplateWrapper {
39 #ifndef EXPECT_NODIAG
40   // expected-error@+2 {{field has incomplete type 'Foo'}}
41 #endif
42   T field;
43 };
44 
45 EXTERN_C void __vectorcall tpl_ok(TemplateWrapper<int> p);
46 void(__vectorcall *fp_tpl_ok)(TemplateWrapper<int>) = &tpl_ok;
47 
48 EXTERN_C void __vectorcall tpl_fast(TemplateWrapper<Foo> p);
49 #ifndef EXPECT_NODIAG
50 // expected-note@+2 {{requested here}}
51 #endif
52 void(__vectorcall *fp_tpl_fast)(TemplateWrapper<Foo>) = &tpl_fast;
53 #endif
54