diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-21 20:29:55 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-21 20:29:55 +0000 |
commit | 27ac429624675306626af028f50cc3bfe172fe7e (patch) | |
tree | 64f609dbd4cc89b8973856c6f632fb80edbd5c2f | |
parent | c425fe4c8014c1f0c921d94ba03d8e137b42a3fa (diff) | |
download | bcm5719-llvm-27ac429624675306626af028f50cc3bfe172fe7e.tar.gz bcm5719-llvm-27ac429624675306626af028f50cc3bfe172fe7e.zip |
Use CanQualType to enforce the use of a canonical type argument to
CXXBasePaths::isAmbiguous(), rather than just asserting that we have a
canonical type. Fixes PR7176.
llvm-svn: 104374
-rw-r--r-- | clang/include/clang/AST/CXXInheritance.h | 2 | ||||
-rw-r--r-- | clang/lib/AST/CXXInheritance.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Sema/SemaCXXCast.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExceptionSpec.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/member-pointer.cpp | 17 |
5 files changed, 22 insertions, 6 deletions
diff --git a/clang/include/clang/AST/CXXInheritance.h b/clang/include/clang/AST/CXXInheritance.h index edd633e8e14..5a84e404a1b 100644 --- a/clang/include/clang/AST/CXXInheritance.h +++ b/clang/include/clang/AST/CXXInheritance.h @@ -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; } diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp index a9f22304586..d616e42e007 100644 --- a/clang/lib/AST/CXXInheritance.cpp +++ b/clang/lib/AST/CXXInheritance.cpp @@ -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; } diff --git a/clang/lib/Sema/SemaCXXCast.cpp b/clang/lib/Sema/SemaCXXCast.cpp index c8eae2fb0a8..9b955525548 100644 --- a/clang/lib/Sema/SemaCXXCast.cpp +++ b/clang/lib/Sema/SemaCXXCast.cpp @@ -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); diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp index 53e9385749f..7d73fe4777b 100644 --- a/clang/lib/Sema/SemaExceptionSpec.cpp +++ b/clang/lib/Sema/SemaExceptionSpec.cpp @@ -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. diff --git a/clang/test/SemaCXX/member-pointer.cpp b/clang/test/SemaCXX/member-pointer.cpp index be25cbdb7ed..9d5cd2fc927 100644 --- a/clang/test/SemaCXX/member-pointer.cpp +++ b/clang/test/SemaCXX/member-pointer.cpp @@ -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; } +} |