xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/virtual-override-x86.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple=i686-pc-win32 -fsyntax-only -verify %s -std=c++11
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc namespace PR14339 {
4f4a2713aSLionel Sambuc   class A {
5f4a2713aSLionel Sambuc   public:
6f4a2713aSLionel Sambuc     virtual void __attribute__((thiscall)) f();	// expected-note{{overridden virtual function is here}}
7f4a2713aSLionel Sambuc   };
8f4a2713aSLionel Sambuc 
9f4a2713aSLionel Sambuc   class B : public A {
10f4a2713aSLionel Sambuc   public:
11f4a2713aSLionel Sambuc     void __attribute__((cdecl)) f();  // expected-error{{virtual function 'f' has different calling convention attributes ('void () __attribute__((cdecl))') than the function it overrides (which has calling convention 'void () __attribute__((thiscall))'}}
12f4a2713aSLionel Sambuc   };
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc   class C : public A {
15f4a2713aSLionel Sambuc   public:
16f4a2713aSLionel Sambuc     void __attribute__((thiscall)) f();  // This override is correct
17f4a2713aSLionel Sambuc   };
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc   class D : public A {
20f4a2713aSLionel Sambuc   public:
21f4a2713aSLionel Sambuc     void f();  // This override is correct because thiscall is the default calling convention for class members
22f4a2713aSLionel Sambuc   };
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc   class E {
25f4a2713aSLionel Sambuc   public:
26f4a2713aSLionel Sambuc     virtual void __attribute__((stdcall)) g();  // expected-note{{overridden virtual function is here}}
27f4a2713aSLionel Sambuc   };
28f4a2713aSLionel Sambuc 
29f4a2713aSLionel Sambuc   class F : public E {
30f4a2713aSLionel Sambuc   public:
31f4a2713aSLionel Sambuc     void g();  // expected-error{{virtual function 'g' has different calling convention attributes ('void () __attribute__((thiscall))') than the function it overrides (which has calling convention 'void () __attribute__((stdcall))'}}
32f4a2713aSLionel Sambuc   };
33f4a2713aSLionel Sambuc }
34