[cfe-commits] r156247 - in /cfe/trunk: lib/AST/DeclCXX.cpp test/SemaCXX/conversion-function.cpp

Richard Smith richard-llvm at metafoo.co.uk
Sat May 5 17:04:33 PDT 2012


Author: rsmith
Date: Sat May  5 19:04:32 2012
New Revision: 156247

URL: http://llvm.org/viewvc/llvm-project?rev=156247&view=rev
Log:
A conversion operator in a base class shouldn't hide another conversion operator
in the same class, even if they convert to the same type. Fixes PR12712.

Modified:
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/test/SemaCXX/conversion-function.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=156247&r1=156246&r2=156247&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Sat May  5 19:04:32 2012
@@ -1050,8 +1050,10 @@
     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.

Modified: cfe/trunk/test/SemaCXX/conversion-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conversion-function.cpp?rev=156247&r1=156246&r2=156247&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/conversion-function.cpp (original)
+++ cfe/trunk/test/SemaCXX/conversion-function.cpp Sat May  5 19:04:32 2012
@@ -392,3 +392,14 @@
     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; }
+}





More information about the cfe-commits mailing list