]> granicus.if.org Git - clang/commitdiff
Note location of operators caused the circularity.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 30 Sep 2009 17:46:20 +0000 (17:46 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 30 Sep 2009 17:46:20 +0000 (17:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83153 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaOverload.cpp
test/SemaCXX/overloaded-operator.cpp

index dafafba474151b12fd47ddc76db538db464c07f8..4e9d7dedaf63b5a8f5e18f0995abd5b240d87a0b 100644 (file)
@@ -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<CanQualType,8> CTypes;
+    llvm::SmallVector<SourceLocation, 8> 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<CXXOperatorCallExpr>(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();
       }
     }
index 9e7661772280424f948c448ec6a647a4959b01fb..aaf76b1a0ec1132263f7c976659c83431d9d123c 100644 (file)
@@ -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);
 }
 
index 31da58dfcd4d479a603ff84a2575995604f4d340..8471f3c936b7007ec0b7802d4ca2de2c4e3da32f 100644 (file)
@@ -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() {