[cfe-commits] r158768 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaCXX/MicrosoftCompatibilityNoExceptions.cpp
Nico Weber
nicolasweber at gmx.de
Tue Jun 19 16:58:27 PDT 2012
Author: nico
Date: Tue Jun 19 18:58:27 2012
New Revision: 158768
URL: http://llvm.org/viewvc/llvm-project?rev=158768&view=rev
Log:
Do a second lookup for type_info in the global namespace in microsoft mode. PR13153.
Added:
cfe/trunk/test/SemaCXX/MicrosoftCompatibilityNoExceptions.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=158768&r1=158767&r2=158768&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jun 19 18:58:27 2012
@@ -374,6 +374,12 @@
LookupResult R(*this, TypeInfoII, SourceLocation(), LookupTagName);
LookupQualifiedName(R, getStdNamespace());
CXXTypeInfoDecl = R.getAsSingle<RecordDecl>();
+ // Microsoft's typeinfo doesn't have type_info in std but in the global
+ // namespace if _HAS_EXCEPTIONS is defined to 0. See PR13153.
+ if (!CXXTypeInfoDecl && LangOpts.MicrosoftMode) {
+ LookupQualifiedName(R, Context.getTranslationUnitDecl());
+ CXXTypeInfoDecl = R.getAsSingle<RecordDecl>();
+ }
if (!CXXTypeInfoDecl)
return ExprError(Diag(OpLoc, diag::err_need_header_before_typeid));
}
Added: cfe/trunk/test/SemaCXX/MicrosoftCompatibilityNoExceptions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibilityNoExceptions.cpp?rev=158768&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibilityNoExceptions.cpp (added)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibilityNoExceptions.cpp Tue Jun 19 18:58:27 2012
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility
+
+// PR13153
+namespace std {}
+class type_info {};
+void f() {
+ (void)typeid(int);
+}
More information about the cfe-commits
mailing list