]> granicus.if.org Git - clang/commitdiff
Use CanQualType to enforce the use of a canonical type argument to
authorDouglas Gregor <dgregor@apple.com>
Fri, 21 May 2010 20:29:55 +0000 (20:29 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 21 May 2010 20:29:55 +0000 (20:29 +0000)
CXXBasePaths::isAmbiguous(), rather than just asserting that we have a
canonical type. Fixes PR7176.

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

include/clang/AST/CXXInheritance.h
lib/AST/CXXInheritance.cpp
lib/Sema/SemaCXXCast.cpp
lib/Sema/SemaExceptionSpec.cpp
test/SemaCXX/member-pointer.cpp

index edd633e8e14087e51f013fada45a96528168ea8f..5a84e404a1b6b5fdfcb59b8676d09c9376b65247 100644 (file)
@@ -196,7 +196,7 @@ public:
   /// \brief Determine whether the path from the most-derived type to the
   /// given base type is ambiguous (i.e., it refers to multiple subobjects of
   /// the same base type).
-  bool isAmbiguous(QualType BaseType);
+  bool isAmbiguous(CanQualType BaseType);
   
   /// \brief Whether we are finding multiple paths to detect ambiguities.
   bool isFindingAmbiguities() const { return FindAmbiguities; }
index a9f22304586416aef60e3fd5dbf351011fa2b4ad..d616e42e00766ce79f89c83021c23f74f0e9fe1f 100644 (file)
@@ -49,9 +49,8 @@ CXXBasePaths::decl_iterator CXXBasePaths::found_decls_end() {
 /// ambiguous, i.e., there are two or more paths that refer to
 /// different base class subobjects of the same type. BaseType must be
 /// an unqualified, canonical class type.
-bool CXXBasePaths::isAmbiguous(QualType BaseType) {
-  assert(BaseType.isCanonical() && "Base type must be the canonical type");
-  assert(BaseType.hasQualifiers() == 0 && "Base type must be unqualified");
+bool CXXBasePaths::isAmbiguous(CanQualType BaseType) {
+  BaseType = BaseType.getUnqualifiedType();
   std::pair<bool, unsigned>& Subobjects = ClassSubobjects[BaseType];
   return Subobjects.second + (Subobjects.first? 1 : 0) > 1;
 }
index c8eae2fb0a82db73761f19543a11983e027e8593..9b95552554897e154d641ecca72148c94c57585e 100644 (file)
@@ -859,7 +859,7 @@ TryStaticMemberPointerUpcast(Sema &Self, Expr *&SrcExpr, QualType SrcType,
   }
 
   // B is a base of D. But is it an allowed base? If not, it's a hard error.
-  if (Paths.isAmbiguous(DestClass)) {
+  if (Paths.isAmbiguous(Self.Context.getCanonicalType(DestClass))) {
     Paths.clear();
     Paths.setRecordingPaths(true);
     bool StillOkay = Self.IsDerivedFrom(SrcClass, DestClass, Paths);
index 53e9385749fb876328d8411af089e4e20f0b7c05..7d73fe4777bd990f6e7f4a3ca6fc4a20576c5aba 100644 (file)
@@ -389,7 +389,7 @@ bool Sema::CheckExceptionSpecSubset(
       if (!IsDerivedFrom(CanonicalSubT, CanonicalSuperT, Paths))
         continue;
 
-      if (Paths.isAmbiguous(CanonicalSuperT))
+      if (Paths.isAmbiguous(Context.getCanonicalType(CanonicalSuperT)))
         continue;
 
       // Do this check from a context without privileges.
index be25cbdb7ed0308efc9feb33a16ef74537e00ea4..9d5cd2fc9273c6f0b3c12284b1995cafba234dcf 100644 (file)
@@ -157,3 +157,20 @@ namespace pr6783 {
     return object->*p2m; // expected-error {{left hand operand to ->*}}
   }
 }
+
+namespace PR7176 {
+  namespace base
+  {
+    struct Process
+    { };
+    struct Continuous : Process
+    {
+      bool cond();
+    };
+  }
+
+  typedef bool( base::Process::*Condition )();
+
+  void m()
+  { (void)(Condition) &base::Continuous::cond; }
+}