From: Fariborz Jahanian Date: Wed, 30 Sep 2009 17:46:20 +0000 (+0000) Subject: Note location of operators caused the circularity. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a8233a69103a6eeb6602bd4a17fb5d9b7bacaad;p=clang Note location of operators caused the circularity. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83153 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index dafafba474..4e9d7dedaf 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1979,6 +1979,7 @@ Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc, if (OpKind == tok::arrow) { // The set of types we've considered so far. llvm::SmallPtrSet CTypes; + llvm::SmallVector Locations; CTypes.insert(Context.getCanonicalType(BaseType)); while (BaseType->isRecordType()) { @@ -1986,11 +1987,14 @@ Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc, BaseExpr = (Expr*)Base.get(); if (BaseExpr == NULL) return ExprError(); + if (CXXOperatorCallExpr *OpCall = dyn_cast(BaseExpr)) + Locations.push_back(OpCall->getOperatorLoc()); BaseType = BaseExpr->getType(); CanQualType CBaseType = Context.getCanonicalType(BaseType); if (!CTypes.insert(CBaseType)) { - // TODO: note the chain of conversions Diag(OpLoc, diag::err_operator_arrow_circular); + for (unsigned i = 0; i < Locations.size(); i++) + Diag(Locations[i], diag::note_declared_at); return ExprError(); } } diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 9e76617722..aaf76b1a0e 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -5065,7 +5065,7 @@ Sema::BuildOverloadedArrowExpr(Scope *S, ExprArg BaseIn, SourceLocation OpLoc) { UsualUnaryConversions(FnExpr); Base = new (Context) CXXOperatorCallExpr(Context, OO_Arrow, FnExpr, &Base, 1, Method->getResultType().getNonReferenceType(), - OpLoc); + Method->getLocation()); return Owned(Base); } diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp index 31da58dfcd..8471f3c936 100644 --- a/test/SemaCXX/overloaded-operator.cpp +++ b/test/SemaCXX/overloaded-operator.cpp @@ -216,7 +216,7 @@ bool x(BB y, BB z) { return y != z; } struct AX { - AX& operator ->(); + AX& operator ->(); // expected-note {{declared at}} int b; }; @@ -226,14 +226,14 @@ void m() { } struct CircA { - struct CircB& operator->(); + struct CircB& operator->(); // expected-note {{declared at}} int val; }; struct CircB { - struct CircC& operator->(); + struct CircC& operator->(); // expected-note {{declared at}} }; struct CircC { - struct CircA& operator->(); + struct CircA& operator->(); // expected-note {{declared at}} }; void circ() {