xref: /llvm-project/clang/test/CXX/expr/expr.mptr.oper/p5.cpp (revision 6ed7251683571ce079f34610da986254821f43e1)
1125fa40cSDouglas Gregor // RUN: %clang_cc1 -fsyntax-only -verify %s
2125fa40cSDouglas Gregor 
3125fa40cSDouglas Gregor struct X0 {
4125fa40cSDouglas Gregor   void f0();
5125fa40cSDouglas Gregor   void f1() const;
6125fa40cSDouglas Gregor   void f2() volatile;
7125fa40cSDouglas Gregor   void f3() const volatile;
8125fa40cSDouglas Gregor };
9125fa40cSDouglas Gregor 
test_object_cvquals(void (X0::* pm)(),void (X0::* pmc)()const,void (X0::* pmv)()volatile,void (X0::* pmcv)()const volatile,X0 * p,const X0 * pc,volatile X0 * pv,const volatile X0 * pcv,X0 & o,const X0 & oc,volatile X0 & ov,const volatile X0 & ocv)10125fa40cSDouglas Gregor void test_object_cvquals(void (X0::*pm)(),
11125fa40cSDouglas Gregor                          void (X0::*pmc)() const,
12125fa40cSDouglas Gregor                          void (X0::*pmv)() volatile,
13125fa40cSDouglas Gregor                          void (X0::*pmcv)() const volatile,
14125fa40cSDouglas Gregor                          X0 *p,
15125fa40cSDouglas Gregor                          const X0 *pc,
16125fa40cSDouglas Gregor                          volatile X0 *pv,
17125fa40cSDouglas Gregor                          const volatile X0 *pcv,
18125fa40cSDouglas Gregor                          X0 &o,
19125fa40cSDouglas Gregor                          const X0 &oc,
20125fa40cSDouglas Gregor                          volatile X0 &ov,
21125fa40cSDouglas Gregor                          const volatile X0 &ocv) {
22125fa40cSDouglas Gregor   (p->*pm)();
23125fa40cSDouglas Gregor   (p->*pmc)();
24125fa40cSDouglas Gregor   (p->*pmv)();
25125fa40cSDouglas Gregor   (p->*pmcv)();
26125fa40cSDouglas Gregor 
27*6ed72516SAlp Toker   (pc->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const' qualifier}}
28125fa40cSDouglas Gregor   (pc->*pmc)();
29*6ed72516SAlp Toker   (pc->*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}}
30125fa40cSDouglas Gregor   (pc->*pmcv)();
31125fa40cSDouglas Gregor 
32*6ed72516SAlp Toker   (pv->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'volatile' qualifier}}
33*6ed72516SAlp Toker   (pv->*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}}
34125fa40cSDouglas Gregor   (pv->*pmv)();
35125fa40cSDouglas Gregor   (pv->*pmcv)();
36125fa40cSDouglas Gregor 
37*6ed72516SAlp Toker   (pcv->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const volatile' qualifiers}}
38*6ed72516SAlp Toker   (pcv->*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}}
39*6ed72516SAlp Toker   (pcv->*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}}
40125fa40cSDouglas Gregor   (pcv->*pmcv)();
41125fa40cSDouglas Gregor 
42125fa40cSDouglas Gregor   (o.*pm)();
43125fa40cSDouglas Gregor   (o.*pmc)();
44125fa40cSDouglas Gregor   (o.*pmv)();
45125fa40cSDouglas Gregor   (o.*pmcv)();
46125fa40cSDouglas Gregor 
47*6ed72516SAlp Toker   (oc.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const' qualifier}}
48125fa40cSDouglas Gregor   (oc.*pmc)();
49*6ed72516SAlp Toker   (oc.*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}}
50125fa40cSDouglas Gregor   (oc.*pmcv)();
51125fa40cSDouglas Gregor 
52*6ed72516SAlp Toker   (ov.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'volatile' qualifier}}
53*6ed72516SAlp Toker   (ov.*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}}
54125fa40cSDouglas Gregor   (ov.*pmv)();
55125fa40cSDouglas Gregor   (ov.*pmcv)();
56125fa40cSDouglas Gregor 
57*6ed72516SAlp Toker   (ocv.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const volatile' qualifiers}}
58*6ed72516SAlp Toker   (ocv.*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}}
59*6ed72516SAlp Toker   (ocv.*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}}
60125fa40cSDouglas Gregor   (ocv.*pmcv)();
61125fa40cSDouglas Gregor }
62