DR61 affirms that expressions containing unresolved member access should
be disallowed when performing "address of" operations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183723
91177308-0d34-0410-b5e6-
96231b3b80d8
<< OrigOp.get()->getSourceRange();
return QualType();
}
-
+
+ OverloadExpr *Ovl = cast<OverloadExpr>(OrigOp.get()->IgnoreParens());
+ if (isa<UnresolvedMemberExpr>(Ovl))
+ if (!S.ResolveSingleFunctionTemplateSpecialization(Ovl)) {
+ S.Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
+ << OrigOp.get()->getSourceRange();
+ return QualType();
+ }
+
return S.Context.OverloadTy;
}
int &n = f(k);
}
-namespace dr61 { // dr61: no
+namespace dr61 { // dr61: yes
struct X {
static void f();
} x;
// This is (presumably) valid, because x.f does not refer to an overloaded
// function name.
void (*p)() = &x.f;
- // FIXME: This should be rejected.
- void (*q)() = &y.f;
+ void (*q)() = &y.f; // expected-error {{cannot create a non-constant pointer to member function}}
}
namespace dr62 { // dr62: yes
};
void A::test() {
- int (A::*ptr)(int) = &(A::foo); // expected-error {{can't form member pointer of type 'int (test2::A::*)(int)' without '&' and class name}}
+ // FIXME: The error message in this case is less than clear, we can do
+ // better.
+ int (A::*ptr)(int) = &(A::foo); // expected-error {{cannot create a non-constant pointer to member function}}
}
}
static T f() { T::error; } // expected-error {{has no members}}
static T f(bool);
};
-void (*p)() = &X<void>().f; // expected-note {{instantiation of}}
+void (*p)() = &X<void>::f; // expected-note {{instantiation of}}
namespace PR13098 {
struct A {
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#7">7</a></td>
<td>NAD</td>
<td>Can a class with a private virtual base class be derived from?</td>
- <td class="none" align="center">No</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#8">8</a></td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#61">61</a></td>
<td>NAD</td>
<td>Address of static member function "<TT>&p->f</TT>"</td>
- <td class="none" align="center">No</td>
+ <td class="full" align="center">Yes</td>
</tr>
<tr>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#62">62</a></td>