[cfe-commits] r84030 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/incomplete-call.cpp
Anders Carlsson
andersca at mac.com
Tue Oct 13 14:19:37 PDT 2009
Author: andersca
Date: Tue Oct 13 16:19:37 2009
New Revision: 84030
URL: http://llvm.org/viewvc/llvm-project?rev=84030&view=rev
Log:
Diagnose invalid return types for unary operators.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/incomplete-call.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=84030&r1=84029&r2=84030&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Oct 13 16:19:37 2009
@@ -4526,9 +4526,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(),
@@ -4537,9 +4535,15 @@
input.release();
- Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
- &Input, 1, ResultTy, OpLoc);
- return MaybeBindToTemporary(CE);
+ ExprOwningPtr<CallExpr> TheCall(this,
+ new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
+ &Input, 1, ResultTy, OpLoc));
+
+ if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall.get(),
+ FnDecl))
+ return ExprError();
+
+ return MaybeBindToTemporary(TheCall.release());
} 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/test/SemaCXX/incomplete-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/incomplete-call.cpp?rev=84030&r1=84029&r2=84030&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/incomplete-call.cpp (original)
+++ cfe/trunk/test/SemaCXX/incomplete-call.cpp Tue Oct 13 16:19:37 2009
@@ -1,5 +1,5 @@
// RUN: clang-cc -fsyntax-only -verify %s
-struct A; // expected-note 6 {{forward declaration of 'struct A'}}
+struct A; // expected-note 8 {{forward declaration of 'struct A'}}
A f(); // expected-note {{note: 'f' declared here}}
@@ -7,6 +7,7 @@
A f(); // expected-note {{'f' declared here}}
A operator()(); // expected-note {{'operator()' declared here}}
operator A(); // expected-note {{'operator A' declared here}}
+ A operator!(); // expected-note 2 {{'operator!' declared here}}
};
void g() {
@@ -22,4 +23,7 @@
b.operator()(); // expected-error {{calling 'operator()' with incomplete return type 'struct A'}}
b.operator A(); // expected-error {{calling 'operator A' with incomplete return type 'struct A'}}
+ b.operator!(); // 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