Skip to content

Commit ca2b71d

Browse files
author
git apple-llvm automerger
committed
Merge commit '55507110b988' from llvm.org/master into apple/master
2 parents e4c84c7 + 5550711 commit ca2b71d

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6688,10 +6688,10 @@ def err_downcast_from_inaccessible_base : Error<
66886688
def err_upcast_to_inaccessible_base : Error<
66896689
"cannot cast %0 to its %select{private|protected}2 base class %1">;
66906690
def err_bad_dynamic_cast_not_ref_or_ptr : Error<
6691-
"%0 is not a reference or pointer">;
6692-
def err_bad_dynamic_cast_not_class : Error<"%0 is not a class">;
6691+
"invalid target type %0 for dynamic_cast; target type must be a reference or pointer type to a defined class">;
6692+
def err_bad_dynamic_cast_not_class : Error<"%0 is not a class type">;
66936693
def err_bad_dynamic_cast_incomplete : Error<"%0 is an incomplete type">;
6694-
def err_bad_dynamic_cast_not_ptr : Error<"%0 is not a pointer">;
6694+
def err_bad_dynamic_cast_not_ptr : Error<"cannot use dynamic_cast to convert from %0 to %1">;
66956695
def err_bad_dynamic_cast_not_polymorphic : Error<"%0 is not polymorphic">;
66966696

66976697
// Other C++ expressions

clang/lib/Sema/SemaCast.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ void CastOperation::CheckDynamicCast() {
773773
SrcPointee = SrcPointer->getPointeeType();
774774
} else {
775775
Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ptr)
776-
<< OrigSrcType << SrcExpr.get()->getSourceRange();
776+
<< OrigSrcType << this->DestType << SrcExpr.get()->getSourceRange();
777777
SrcExpr = ExprError();
778778
return;
779779
}

clang/test/SemaCXX/dynamic-cast.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ struct PolyDerived : Poly
2222
void basic_bad()
2323
{
2424
// ptr -> nonptr
25-
(void)dynamic_cast<A>((A*)0); // expected-error {{'A' is not a reference or pointer}}
25+
(void)dynamic_cast<A>((A*)0); // expected-error {{invalid target type 'A' for dynamic_cast; target type must be a reference or pointer type to a defined class}}
2626
// nonptr -> ptr
27-
(void)dynamic_cast<A*>(0); // expected-error {{'int' is not a pointer}}
27+
(void)dynamic_cast<A*>(0); // expected-error {{cannot use dynamic_cast to convert from 'int' to 'A *'}}
2828
// ptr -> noncls
29-
(void)dynamic_cast<int*>((A*)0); // expected-error {{'int' is not a class}}
29+
(void)dynamic_cast<int*>((A*)0); // expected-error {{'int' is not a class type}}
3030
// noncls -> ptr
31-
(void)dynamic_cast<A*>((int*)0); // expected-error {{'int' is not a class}}
31+
(void)dynamic_cast<A*>((int*)0); // expected-error {{'int' is not a class type}}
3232
// ref -> noncls
33-
(void)dynamic_cast<int&>(*((A*)0)); // expected-error {{'int' is not a class}}
33+
(void)dynamic_cast<int&>(*((A*)0)); // expected-error {{'int' is not a class type}}
3434
// noncls -> ref
35-
(void)dynamic_cast<A&>(*((int*)0)); // expected-error {{'int' is not a class}}
35+
(void)dynamic_cast<A&>(*((int*)0)); // expected-error {{'int' is not a class type}}
3636
// ptr -> incomplete
3737
(void)dynamic_cast<Incomplete*>((A*)0); // expected-error {{'Incomplete' is an incomplete type}}
3838
// incomplete -> ptr

clang/test/SemaTemplate/instantiate-cast.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ template struct StaticCast0<int, A>; // expected-note{{instantiation}}
5757
template<typename T, typename U>
5858
struct DynamicCast0 {
5959
void f(T t) {
60-
(void)dynamic_cast<U>(t); // expected-error{{not a reference or pointer}}
60+
(void)dynamic_cast<U>(t); // expected-error{{invalid target type 'A' for dynamic_cast; target type must be a reference or pointer type to a defined class}}
6161
}
6262
};
6363

0 commit comments

Comments
 (0)