aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-27 21:10:04 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-27 21:10:04 +0000
commit15dedf067b65151f0fd89dd9f80cea96a0528db1 (patch)
treec72b48559394d056d11fc82af894733d0fffbeda
parent493ec51db3a0cfa6f32e612c92c8eb0580dc9ebc (diff)
It's okay to refer to non-type template parameters anywhere they are
visible. Fixes the remaining two failures in Boost.ScopeExit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102466 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp5
-rw-r--r--test/SemaCXX/local-classes.cpp9
2 files changed, 13 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)
diff --git a/test/SemaCXX/local-classes.cpp b/test/SemaCXX/local-classes.cpp
index 6799e58e95..500b2197ef 100644
--- a/test/SemaCXX/local-classes.cpp
+++ b/test/SemaCXX/local-classes.cpp
@@ -30,3 +30,12 @@ namespace PR6383 {
compare_and_set2 (false, gross);
}
}
+
+namespace Templates {
+ template<int Value>
+ void f() {
+ struct Inner {
+ static int getValue() { return Value; }
+ };
+ }
+}