Error when using typeid() with -fno-rtti. PR 12888.

llvm-svn: 157139
This commit is contained in:
Nico Weber 2012-05-20 01:27:21 +00:00
parent 022900079b
commit 1b7f39de3d
3 changed files with 17 additions and 0 deletions

View File

@ -4392,6 +4392,9 @@ def err_invalid_declarator_in_function : Error<
def err_not_tag_in_scope : Error<
"no %select{struct|union|class|enum}0 named %1 in %2">;
def err_no_typeid_with_fno_rtti : Error<
"cannot use typeid with -fno-rtti">;
def err_cannot_form_pointer_to_member_of_reference_type : Error<
"cannot form a pointer-to-member to member %0 of reference type %1">;
def err_incomplete_object_call : Error<

View File

@ -379,6 +379,10 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc,
return ExprError(Diag(OpLoc, diag::err_need_header_before_typeid));
}
if (!getLangOpts().RTTI) {
return ExprError(Diag(OpLoc, diag::err_no_typeid_with_fno_rtti));
}
QualType TypeInfoType = Context.getTypeDeclType(CXXTypeInfoDecl);
if (isType) {

View File

@ -0,0 +1,10 @@
// RUN: %clang_cc1 -fsyntax-only -verify -fno-rtti %s
namespace std {
class type_info;
}
void f()
{
(void)typeid(int); // expected-error {{cannot use typeid with -fno-rtti}}
}