Douglas Gregor | 125fa40 | 2011-02-04 12:57:49 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | struct X0 { |
| 4 | void f0(); |
| 5 | void f1() const; |
| 6 | void f2() volatile; |
| 7 | void f3() const volatile; |
| 8 | }; |
| 9 | |
| 10 | void test_object_cvquals(void (X0::*pm)(), |
| 11 | void (X0::*pmc)() const, |
| 12 | void (X0::*pmv)() volatile, |
| 13 | void (X0::*pmcv)() const volatile, |
| 14 | X0 *p, |
| 15 | const X0 *pc, |
| 16 | volatile X0 *pv, |
| 17 | const volatile X0 *pcv, |
| 18 | X0 &o, |
| 19 | const X0 &oc, |
| 20 | volatile X0 &ov, |
| 21 | const volatile X0 &ocv) { |
| 22 | (p->*pm)(); |
| 23 | (p->*pmc)(); |
| 24 | (p->*pmv)(); |
| 25 | (p->*pmcv)(); |
| 26 | |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 27 | (pc->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const' qualifier}} |
Douglas Gregor | 125fa40 | 2011-02-04 12:57:49 +0000 | [diff] [blame] | 28 | (pc->*pmc)(); |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 29 | (pc->*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} |
Douglas Gregor | 125fa40 | 2011-02-04 12:57:49 +0000 | [diff] [blame] | 30 | (pc->*pmcv)(); |
| 31 | |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 32 | (pv->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'volatile' qualifier}} |
| 33 | (pv->*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} |
Douglas Gregor | 125fa40 | 2011-02-04 12:57:49 +0000 | [diff] [blame] | 34 | (pv->*pmv)(); |
| 35 | (pv->*pmcv)(); |
| 36 | |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 37 | (pcv->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const volatile' qualifiers}} |
| 38 | (pcv->*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} |
| 39 | (pcv->*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} |
Douglas Gregor | 125fa40 | 2011-02-04 12:57:49 +0000 | [diff] [blame] | 40 | (pcv->*pmcv)(); |
| 41 | |
| 42 | (o.*pm)(); |
| 43 | (o.*pmc)(); |
| 44 | (o.*pmv)(); |
| 45 | (o.*pmcv)(); |
| 46 | |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 47 | (oc.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const' qualifier}} |
Douglas Gregor | 125fa40 | 2011-02-04 12:57:49 +0000 | [diff] [blame] | 48 | (oc.*pmc)(); |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 49 | (oc.*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} |
Douglas Gregor | 125fa40 | 2011-02-04 12:57:49 +0000 | [diff] [blame] | 50 | (oc.*pmcv)(); |
| 51 | |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 52 | (ov.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'volatile' qualifier}} |
| 53 | (ov.*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} |
Douglas Gregor | 125fa40 | 2011-02-04 12:57:49 +0000 | [diff] [blame] | 54 | (ov.*pmv)(); |
| 55 | (ov.*pmcv)(); |
| 56 | |
Alp Toker | 6ed7251 | 2013-12-14 01:07:05 +0000 | [diff] [blame] | 57 | (ocv.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const volatile' qualifiers}} |
| 58 | (ocv.*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} |
| 59 | (ocv.*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} |
Douglas Gregor | 125fa40 | 2011-02-04 12:57:49 +0000 | [diff] [blame] | 60 | (ocv.*pmcv)(); |
| 61 | } |