[cfe-commits] r157139 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprCXX.cpp test/SemaCXX/no-rtti.cpp
Nico Weber
nicolasweber at gmx.de
Sat May 19 18:27:21 PDT 2012
Author: nico
Date: Sat May 19 20:27:21 2012
New Revision: 157139
URL: http://llvm.org/viewvc/llvm-project?rev=157139&view=rev
Log:
Error when using typeid() with -fno-rtti. PR 12888.
Added:
cfe/trunk/test/SemaCXX/no-rtti.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=157139&r1=157138&r2=157139&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat May 19 20:27:21 2012
@@ -4392,6 +4392,9 @@
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<
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=157139&r1=157138&r2=157139&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sat May 19 20:27:21 2012
@@ -379,6 +379,10 @@
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) {
Added: cfe/trunk/test/SemaCXX/no-rtti.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/no-rtti.cpp?rev=157139&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/no-rtti.cpp (added)
+++ cfe/trunk/test/SemaCXX/no-rtti.cpp Sat May 19 20:27:21 2012
@@ -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}}
+}
More information about the cfe-commits
mailing list