diff options
-rw-r--r-- | lib/AST/Expr.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/pr13353.cpp | 13 |
3 files changed, 16 insertions, 2 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index f2f77367d8..47b5625b92 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -40,6 +40,9 @@ const CXXRecordDecl *Expr::getBestDynamicClassType() const { if (const PointerType *PTy = DerivedType->getAs<PointerType>()) DerivedType = PTy->getPointeeType(); + if (DerivedType->isDependentType()) + return NULL; + const RecordType *Ty = DerivedType->castAs<RecordType>(); Decl *D = Ty->getDecl(); return cast<CXXRecordDecl>(D); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 915663e622..177165c79e 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -10893,8 +10893,6 @@ static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, if (!MD) return; const Expr *Base = ME->getBase(); - if (Base->getType()->isDependentType()) - return; const CXXRecordDecl *MostDerivedClassDecl = Base->getBestDynamicClassType(); if (!MostDerivedClassDecl) return; diff --git a/test/SemaCXX/pr13353.cpp b/test/SemaCXX/pr13353.cpp new file mode 100644 index 0000000000..8fb5443fe6 --- /dev/null +++ b/test/SemaCXX/pr13353.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only %s +struct foo { + virtual void bar() ; +}; +template<typename T> +class zed : public foo { +}; +template<typename T> +class bah : public zed<T> { + void f() { + const_cast<foo *>(this->g())->bar(); + } +}; |