[cfe-commits] r84161 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/incomplete-call.cpp
Anders Carlsson
andersca at mac.com
Wed Oct 14 17:41:48 PDT 2009
Author: andersca
Date: Wed Oct 14 19:41:48 2009
New Revision: 84161
URL: http://llvm.org/viewvc/llvm-project?rev=84161&view=rev
Log:
Check the return type when calling pointer to member functions.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/incomplete-call.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=84161&r1=84160&r2=84161&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Oct 14 19:41:48 2009
@@ -2917,15 +2917,18 @@
if (BO->getOpcode() == BinaryOperator::PtrMemD ||
BO->getOpcode() == BinaryOperator::PtrMemI) {
const FunctionProtoType *FPT = cast<FunctionProtoType>(BO->getType());
- QualType ReturnTy = FPT->getResultType();
+ QualType ResultTy = FPT->getResultType().getNonReferenceType();
- CXXMemberCallExpr *CE =
- new (Context) CXXMemberCallExpr(Context, BO, Args, NumArgs,
- ReturnTy.getNonReferenceType(),
- RParenLoc);
-
- ExprOwningPtr<CXXMemberCallExpr> TheCall(this, CE);
+ ExprOwningPtr<CXXMemberCallExpr>
+ TheCall(this, new (Context) CXXMemberCallExpr(Context, BO, Args,
+ NumArgs, ResultTy,
+ RParenLoc));
+ if (CheckCallReturnType(FPT->getResultType(),
+ BO->getRHS()->getSourceRange().getBegin(),
+ TheCall.get(), 0))
+ return ExprError();
+
if (ConvertArgumentsForCall(&*TheCall, BO, 0, FPT, Args, NumArgs,
RParenLoc))
return ExprError();
Modified: cfe/trunk/test/SemaCXX/incomplete-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/incomplete-call.cpp?rev=84161&r1=84160&r2=84161&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/incomplete-call.cpp (original)
+++ cfe/trunk/test/SemaCXX/incomplete-call.cpp Wed Oct 14 19:41:48 2009
@@ -1,5 +1,5 @@
// RUN: clang-cc -fsyntax-only -verify %s
-struct A; // expected-note 13 {{forward declaration of 'struct A'}}
+struct A; // expected-note 14 {{forward declaration of 'struct A'}}
A f(); // expected-note {{note: 'f' declared here}}
@@ -35,4 +35,8 @@
b[0]; // expected-error {{calling 'operator[]' with incomplete return type 'struct A'}}
b + 1; // expected-error {{calling 'operator+' with incomplete return type 'struct A'}}
b->f(); // expected-error {{calling 'operator->' with incomplete return type 'struct A'}}
+
+ A (B::*mfp)() = 0;
+ (b.*mfp)(); // expected-error {{calling function with incomplete return type 'struct A'}}
+
}
More information about the cfe-commits
mailing list