summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2013-07-31 17:38:24 +0000
committerKaelyn Uhrain <rikka@google.com>2013-07-31 17:38:24 +0000
commitbaaeb85f07640794f6a4fabb871e33deeab07df2 (patch)
tree74ba63f2b889e4ed835f9c250ee3c7da4a671a06 /lib/Sema/SemaOverload.cpp
parentb316dc517d9721ac9047819e4eeaa0eb59c4020a (diff)
downloadclang-baaeb85f07640794f6a4fabb871e33deeab07df2.tar.gz
clang-baaeb85f07640794f6a4fabb871e33deeab07df2.tar.bz2
clang-baaeb85f07640794f6a4fabb871e33deeab07df2.tar.xz
Improve the diagnostic experience, including adding recovery, for
changing '->' to '.' when there is no operator-> defined for a class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187504 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r--lib/Sema/SemaOverload.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 7ebcd88fe5..7241551893 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -11463,7 +11463,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
/// (if one exists), where @c Base is an expression of class type and
/// @c Member is the name of the member we're trying to find.
ExprResult
-Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc) {
+Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc,
+ bool *NoArrowOperatorFound) {
assert(Base->getType()->isRecordType() &&
"left-hand side must have class type");
@@ -11509,6 +11510,12 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc) {
case OR_No_Viable_Function:
if (CandidateSet.empty()) {
QualType BaseType = Base->getType();
+ if (NoArrowOperatorFound) {
+ // Report this specific error to the caller instead of emitting a
+ // diagnostic, as requested.
+ *NoArrowOperatorFound = true;
+ return ExprError();
+ }
Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
<< BaseType << Base->getSourceRange();
if (BaseType->isRecordType() && !BaseType->isPointerType()) {