Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / expr / expr.mptr.oper / p6-0x.cpp
blobb1823e59fff28493fb466ea630a7ab91bd49d98a
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
3 struct X { };
5 template<typename T> T& lvalue();
6 template<typename T> T&& xvalue();
7 template<typename T> T prvalue();
9 // In a .* expression whose object expression is an rvalue, the
10 // program is ill-formed if the second operand is a pointer to member
11 // function with ref-qualifier &. In a ->* expression or in a .*
12 // expression whose object expression is an lvalue, the program is
13 // ill-formed if the second operand is a pointer to member function
14 // with ref-qualifier &&.
15 void test(X *xp, int (X::*pmf)(int), int (X::*l_pmf)(int) &,
16 int (X::*r_pmf)(int) &&) {
17 // No ref-qualifier.
18 (lvalue<X>().*pmf)(17);
19 (xvalue<X>().*pmf)(17);
20 (prvalue<X>().*pmf)(17);
21 (xp->*pmf)(17);
23 // Lvalue ref-qualifier.
24 (lvalue<X>().*l_pmf)(17);
25 (xvalue<X>().*l_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &' can only be called on an lvalue}}
26 (prvalue<X>().*l_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &' can only be called on an lvalue}}
27 (xp->*l_pmf)(17);
29 // Rvalue ref-qualifier.
30 (lvalue<X>().*r_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &&' can only be called on an rvalue}}
31 (xvalue<X>().*r_pmf)(17);
32 (prvalue<X>().*r_pmf)(17);
33 (xp->*r_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &&' can only be called on an rvalue}}