diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 997b8f8dcb..89a329140f 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -459,7 +459,10 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, SourceLocation Loc, } if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { - if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext)) { + if (isa<NonTypeTemplateParmDecl>(VD)) { + // Non-type template parameters can be referenced anywhere they are + // visible. + } else if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext)) { if (const FunctionDecl *FD = MD->getParent()->isLocalClass()) { if (VD->hasLocalStorage() && VD->getDeclContext() != CurContext) { Diag(Loc, diag::err_reference_to_local_var_in_enclosing_function) |