]> granicus.if.org Git - clang/commitdiff
A conversion operator in a base class shouldn't hide another conversion operator
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 6 May 2012 00:04:32 +0000 (00:04 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 6 May 2012 00:04:32 +0000 (00:04 +0000)
in the same class, even if they convert to the same type. Fixes PR12712.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156247 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp
test/SemaCXX/conversion-function.cpp

index f19184c3a4ed32ad3270dae25abfe4303c486497..e27d880ecf9b87111880cd77321db88e5c095f17 100644 (file)
@@ -1050,8 +1050,10 @@ static void CollectVisibleConversions(ASTContext &Context,
     HiddenTypes = &HiddenTypesBuffer;
 
     for (UnresolvedSetIterator I = Cs.begin(), E = Cs.end(); I != E; ++I) {
-      bool Hidden =
-        !HiddenTypesBuffer.insert(GetConversionType(Context, I.getDecl()));
+      CanQualType ConvType(GetConversionType(Context, I.getDecl()));
+      bool Hidden = ParentHiddenTypes.count(ConvType);
+      if (!Hidden)
+        HiddenTypesBuffer.insert(ConvType);
 
       // If this conversion is hidden and we're in a virtual base,
       // remember that it's hidden along some inheritance path.
index a7a178244c80dd0de74eae4676d332be5a5a7290..6fca0503ba72700aca96502ecea8e5da4709c916 100644 (file)
@@ -392,3 +392,14 @@ namespace PR8800 {
     A& a4 = (A&)c;
   }
 }
+
+namespace PR12712 {
+  struct A {};
+  struct B {
+    operator A();
+    operator A() const;
+  };
+  struct C : B {};
+
+  A f(const C c) { return c; }
+}