Do a second lookup for type_info in the global namespace in microsoft mode. PR13153.

llvm-svn: 158768
This commit is contained in:
Nico Weber 2012-06-19 23:58:27 +00:00
parent 3bc72c1ec2
commit 5f96883d44
2 changed files with 14 additions and 0 deletions

View File

@ -374,6 +374,12 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc,
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));
}

View File

@ -0,0 +1,8 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility
// PR13153
namespace std {}
class type_info {};
void f() {
(void)typeid(int);
}