p5.cpp 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. struct X0 {
  3. void f0();
  4. void f1() const;
  5. void f2() volatile;
  6. void f3() const volatile;
  7. };
  8. void test_object_cvquals(void (X0::*pm)(),
  9. void (X0::*pmc)() const,
  10. void (X0::*pmv)() volatile,
  11. void (X0::*pmcv)() const volatile,
  12. X0 *p,
  13. const X0 *pc,
  14. volatile X0 *pv,
  15. const volatile X0 *pcv,
  16. X0 &o,
  17. const X0 &oc,
  18. volatile X0 &ov,
  19. const volatile X0 &ocv) {
  20. (p->*pm)();
  21. (p->*pmc)();
  22. (p->*pmv)();
  23. (p->*pmcv)();
  24. (pc->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const' qualifier}}
  25. (pc->*pmc)();
  26. (pc->*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}}
  27. (pc->*pmcv)();
  28. (pv->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'volatile' qualifier}}
  29. (pv->*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}}
  30. (pv->*pmv)();
  31. (pv->*pmcv)();
  32. (pcv->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const volatile' qualifiers}}
  33. (pcv->*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}}
  34. (pcv->*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}}
  35. (pcv->*pmcv)();
  36. (o.*pm)();
  37. (o.*pmc)();
  38. (o.*pmv)();
  39. (o.*pmcv)();
  40. (oc.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const' qualifier}}
  41. (oc.*pmc)();
  42. (oc.*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}}
  43. (oc.*pmcv)();
  44. (ov.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'volatile' qualifier}}
  45. (ov.*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}}
  46. (ov.*pmv)();
  47. (ov.*pmcv)();
  48. (ocv.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const volatile' qualifiers}}
  49. (ocv.*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}}
  50. (ocv.*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}}
  51. (ocv.*pmcv)();
  52. }