blob: db203c3af1513fa72c4c2a5de71b26834b744944 [file] [log] [blame]
Reid Klecknere78333a2019-06-10 22:53:12 +00001// 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
17struct Foo;
18
19EXTERN_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
23void (__stdcall *fp_fwd_std)(struct Foo) = &fwd_std;
24
25EXTERN_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
29void (__fastcall *fp_fwd_fast)(struct Foo) = &fwd_fast;
30
31EXTERN_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
35void (__vectorcall *fp_fwd_vector)(struct Foo) = &fwd_vector;
36
37#if defined(__cplusplus)
38template <typename T> struct TemplateWrapper {
39#ifndef EXPECT_NODIAG
40 // expected-error@+2 {{field has incomplete type 'Foo'}}
41#endif
42 T field;
43};
44
45EXTERN_C void __vectorcall tpl_ok(TemplateWrapper<int> p);
46void(__vectorcall *fp_tpl_ok)(TemplateWrapper<int>) = &tpl_ok;
47
48EXTERN_C void __vectorcall tpl_fast(TemplateWrapper<Foo> p);
49#ifndef EXPECT_NODIAG
50// expected-note@+2 {{requested here}}
51#endif
52void(__vectorcall *fp_tpl_fast)(TemplateWrapper<Foo>) = &tpl_fast;
53#endif