Skip to content

Commit

Permalink
Change the wording of RTTI errors to make them more generic.
Browse files Browse the repository at this point in the history
An attempt to use dynamic_cast while rtti is disabled, used to emit the error:

  cannot use dynamic_cast with -fno-rtti

and a similar one for typeid.

This patch changes that to:

  use of dynamic_cast requires -frtti

Differential Revision: https://reviews.llvm.org/D47291


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334153 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Sunil Srivastava committed Jun 7, 2018
1 parent 45021ac commit 0e636ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -6607,9 +6607,9 @@ def err_not_tag_in_scope : Error<
"no %select{struct|interface|union|class|enum}0 named %1 in %2">;

def err_no_typeid_with_fno_rtti : Error<
"cannot use typeid with -fno-rtti">;
"use of typeid requires -frtti">;
def err_no_dynamic_cast_with_fno_rtti : Error<
"cannot use dynamic_cast with -fno-rtti">;
"use of dynamic_cast requires -frtti">;

def err_cannot_form_pointer_to_member_of_reference_type : Error<
"cannot form a pointer-to-member to member %0 of reference type %1">;
Expand Down
4 changes: 2 additions & 2 deletions test/SemaCXX/no-rtti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace std {

void f()
{
(void)typeid(int); // expected-error {{cannot use typeid with -fno-rtti}}
(void)typeid(int); // expected-error {{use of typeid requires -frtti}}
}

namespace {
Expand All @@ -20,7 +20,7 @@ struct B : public A {
}

bool isa_B(A *a) {
return dynamic_cast<B *>(a) != 0; // expected-error {{cannot use dynamic_cast with -fno-rtti}}
return dynamic_cast<B *>(a) != 0; // expected-error {{use of dynamic_cast requires -frtti}}
}

void* getMostDerived(A* a) {
Expand Down

0 comments on commit 0e636ed

Please sign in to comment.