r183723 - Implement DR61: Address of ambiguous bound methods should be disallowed
David Majnemer
david.majnemer at gmail.com
Mon Jun 10 20:56:29 PDT 2013
Author: majnemer
Date: Mon Jun 10 22:56:29 2013
New Revision: 183723
URL: http://llvm.org/viewvc/llvm-project?rev=183723&view=rev
Log:
Implement DR61: Address of ambiguous bound methods should be disallowed
DR61 affirms that expressions containing unresolved member access should
be disallowed when performing "address of" operations.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CXX/drs/dr0xx.cpp
cfe/trunk/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp
cfe/trunk/test/SemaTemplate/instantiate-overload-candidates.cpp
cfe/trunk/www/cxx_dr_status.html
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=183723&r1=183722&r2=183723&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jun 10 22:56:29 2013
@@ -8356,7 +8356,15 @@ static QualType CheckAddressOfOperand(Se
<< 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;
}
Modified: cfe/trunk/test/CXX/drs/dr0xx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr0xx.cpp?rev=183723&r1=183722&r2=183723&view=diff
==============================================================================
--- cfe/trunk/test/CXX/drs/dr0xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr0xx.cpp Mon Jun 10 22:56:29 2013
@@ -627,7 +627,7 @@ namespace dr60 { // dr60: yes
int &n = f(k);
}
-namespace dr61 { // dr61: no
+namespace dr61 { // dr61: yes
struct X {
static void f();
} x;
@@ -638,8 +638,7 @@ namespace dr61 { // dr61: no
// 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
Modified: cfe/trunk/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp?rev=183723&r1=183722&r2=183723&view=diff
==============================================================================
--- cfe/trunk/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp (original)
+++ cfe/trunk/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp Mon Jun 10 22:56:29 2013
@@ -38,6 +38,8 @@ namespace test2 {
};
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}}
}
}
Modified: cfe/trunk/test/SemaTemplate/instantiate-overload-candidates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-overload-candidates.cpp?rev=183723&r1=183722&r2=183723&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-overload-candidates.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-overload-candidates.cpp Mon Jun 10 22:56:29 2013
@@ -26,7 +26,7 @@ template<typename T> struct X {
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 {
Modified: cfe/trunk/www/cxx_dr_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=183723&r1=183722&r2=183723&view=diff
==============================================================================
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Mon Jun 10 22:56:29 2013
@@ -80,7 +80,7 @@
<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>
@@ -404,7 +404,7 @@
<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>
More information about the cfe-commits
mailing list