[cfe-commits] r84034 - in /cfe/trunk: lib/Sema/SemaExpr.cpp lib/Sema/SemaOverload.cpp test/SemaCXX/incomplete-call.cpp
Anders Carlsson
andersca at mac.com
Tue Oct 13 14:49:31 PDT 2009
Author: andersca
Date: Tue Oct 13 16:49:31 2009
New Revision: 84034
URL: http://llvm.org/viewvc/llvm-project?rev=84034&view=rev
Log:
More return type checking.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.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=84034&r1=84033&r2=84034&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Oct 13 16:49:31 2009
@@ -1572,9 +1572,7 @@
}
// Determine the result type
- QualType ResultTy
- = FnDecl->getType()->getAs<FunctionType>()->getResultType();
- ResultTy = ResultTy.getNonReferenceType();
+ QualType ResultTy = FnDecl->getResultType().getNonReferenceType();
// Build the actual expression node.
Expr *FnExpr = new (Context) DeclRefExpr(FnDecl, FnDecl->getType(),
@@ -1583,9 +1581,15 @@
Input.release();
Args[0] = Arg;
- return Owned(new (Context) CXXOperatorCallExpr(Context, OverOp, FnExpr,
- Args, 2, ResultTy,
- OpLoc));
+
+ ExprOwningPtr<CXXOperatorCallExpr>
+ TheCall(this, new (Context) CXXOperatorCallExpr(Context, OverOp,
+ FnExpr, Args, 2,
+ ResultTy, OpLoc));
+
+ if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall.get(),
+ FnDecl))
+ return ExprError();
} else {
// We matched a built-in operator. Convert the arguments, then
// break out so that we will build the appropriate built-in
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=84034&r1=84033&r2=84034&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Oct 13 16:49:31 2009
@@ -5050,6 +5050,10 @@
ResultTy, RParenLoc));
delete [] MethodArgs;
+ if (CheckCallReturnType(Method->getResultType(), LParenLoc, TheCall.get(),
+ Method))
+ return true;
+
// We may have default arguments. If so, we need to allocate more
// slots in the call for them.
if (NumArgs < NumArgsInProto)
Modified: cfe/trunk/test/SemaCXX/incomplete-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/incomplete-call.cpp?rev=84034&r1=84033&r2=84034&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/incomplete-call.cpp (original)
+++ cfe/trunk/test/SemaCXX/incomplete-call.cpp Tue Oct 13 16:49:31 2009
@@ -1,13 +1,14 @@
// RUN: clang-cc -fsyntax-only -verify %s
-struct A; // expected-note 8 {{forward declaration of 'struct A'}}
+struct A; // expected-note 10 {{forward declaration of 'struct A'}}
A f(); // expected-note {{note: 'f' declared here}}
struct B {
A f(); // expected-note {{'f' declared here}}
- A operator()(); // expected-note {{'operator()' declared here}}
+ A operator()(); // expected-note 2 {{'operator()' declared here}}
operator A(); // expected-note {{'operator A' declared here}}
A operator!(); // expected-note 2 {{'operator!' declared here}}
+ A operator++(int); // expected-note {{'operator++' declared here}}
};
void g() {
@@ -26,4 +27,6 @@
b.operator!(); // expected-error {{calling 'operator!' with incomplete return type 'struct A'}}
!b; // expected-error {{calling 'operator!' with incomplete return type 'struct A'}}
+ b(); // expected-error {{calling 'operator()' with incomplete return type 'struct A'}}
+ b++; // expected-error {{calling 'operator++' with incomplete return type 'struct A'}}
}
More information about the cfe-commits
mailing list