[cfe-commits] r84041 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/incomplete-call.cpp
Anders Carlsson
andersca at mac.com
Tue Oct 13 15:22:09 PDT 2009
Author: andersca
Date: Tue Oct 13 17:22:09 2009
New Revision: 84041
URL: http://llvm.org/viewvc/llvm-project?rev=84041&view=rev
Log:
Check the return type of operator[]() and fix a thinko that lead to a crash in SemaCXX/overloaded-operator.cpp.
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=84041&r1=84040&r2=84041&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Oct 13 17:22:09 2009
@@ -1590,6 +1590,8 @@
if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall.get(),
FnDecl))
return ExprError();
+ return Owned(TheCall.release());
+
} else {
// We matched a built-in operator. Convert the arguments, then
// break out so that we will build the appropriate built-in
@@ -1700,9 +1702,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(),
@@ -1713,9 +1713,16 @@
Idx.release();
Args[0] = LHSExp;
Args[1] = RHSExp;
- return Owned(new (Context) CXXOperatorCallExpr(Context, OO_Subscript,
- FnExpr, Args, 2,
- ResultTy, LLoc));
+
+ ExprOwningPtr<CXXOperatorCallExpr>
+ TheCall(this, new (Context) CXXOperatorCallExpr(Context, OO_Subscript,
+ FnExpr, Args, 2,
+ ResultTy, RLoc));
+ if (CheckCallReturnType(FnDecl->getResultType(), LLoc, TheCall.get(),
+ FnDecl))
+ return ExprError();
+
+ return Owned(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=84041&r1=84040&r2=84041&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/incomplete-call.cpp (original)
+++ cfe/trunk/test/SemaCXX/incomplete-call.cpp Tue Oct 13 17:22:09 2009
@@ -1,5 +1,5 @@
// RUN: clang-cc -fsyntax-only -verify %s
-struct A; // expected-note 10 {{forward declaration of 'struct A'}}
+struct A; // expected-note 11 {{forward declaration of 'struct A'}}
A f(); // expected-note {{note: 'f' declared here}}
@@ -9,6 +9,7 @@
operator A(); // expected-note {{'operator A' declared here}}
A operator!(); // expected-note 2 {{'operator!' declared here}}
A operator++(int); // expected-note {{'operator++' declared here}}
+ A operator[](int); // expected-note {{'operator[]' declared here}}
};
void g() {
@@ -29,4 +30,5 @@
!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'}}
+ b[0]; // expected-error {{calling 'operator[]' with incomplete return type 'struct A'}}
}
More information about the cfe-commits
mailing list