diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-06-10 23:29:48 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-06-10 23:29:48 +0000 |
commit | 4ed0870592c05a5c6f80268bdaf62a081c47477f (patch) | |
tree | ac488872253455f43e3c99dcd76e809a7c141304 /lib/Sema/SemaExpr.cpp | |
parent | a438edc06abbe6f78fc5cc692b6aaecf0730eb08 (diff) | |
download | clang-4ed0870592c05a5c6f80268bdaf62a081c47477f.tar.gz clang-4ed0870592c05a5c6f80268bdaf62a081c47477f.tar.bz2 clang-4ed0870592c05a5c6f80268bdaf62a081c47477f.tar.xz |
Recover from missing typenames on template args for MSVC compatibility
While matching a non-type template argument against a known template
type parameter we now modify the AST's TemplateArgumentLoc to assume the
user wrote typename. Under -fms-compatibility, we downgrade our
diagnostic from an error to an extwarn.
Reviewed by: rsmith
Differential Revision: http://reviews.llvm.org/D4049
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210607 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 47bcc817e4..d2ba82bc16 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2181,6 +2181,17 @@ Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, return ExprError(); } + if (R.isSingleResult() && R.getAsSingle<TypeDecl>()) { + // Diagnose a missing typename if this resolved unambiguously to a type in a + // dependent context. + // FIXME: Issue a fixit and recover as though the user had written + // 'typename'. + Diag(SS.getBeginLoc(), diag::err_typename_missing) + << SS.getScopeRep() << NameInfo.getName().getAsString() + << SourceRange(SS.getBeginLoc(), NameInfo.getEndLoc()); + return ExprError(); + } + // Defend against this resolving to an implicit member access. We usually // won't get here if this might be a legitimate a class member (we end up in // BuildMemberReferenceExpr instead), but this can be valid if we're forming |