[cfe-commits] r93514 - in /cfe/trunk: lib/AST/Expr.cpp test/SemaTemplate/dependent-expr.cpp
Douglas Gregor
dgregor at apple.com
Fri Jan 15 08:21:02 PST 2010
Author: dgregor
Date: Fri Jan 15 10:21:02 2010
New Revision: 93514
URL: http://llvm.org/viewvc/llvm-project?rev=93514&view=rev
Log:
When determining whether a DeclRefExpr is value-dependent when it
references a const variable of integral type, the initializer may be
in a different declaration than the one that name-lookup saw. Find the
initializer anyway. Fixes PR6045.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/SemaTemplate/dependent-expr.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=93514&r1=93513&r2=93514&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Jan 15 10:21:02 2010
@@ -98,10 +98,12 @@
// initialized with an expression that is value-dependent.
else if (VarDecl *Var = dyn_cast<VarDecl>(D)) {
if (Var->getType()->isIntegralType() &&
- Var->getType().getCVRQualifiers() == Qualifiers::Const &&
- Var->getInit() &&
- Var->getInit()->isValueDependent())
- ValueDependent = true;
+ Var->getType().getCVRQualifiers() == Qualifiers::Const) {
+ const VarDecl *Def = 0;
+ if (const Expr *Init = Var->getDefinition(Def))
+ if (Init->isValueDependent())
+ ValueDependent = true;
+ }
}
// (TD) - a nested-name-specifier or a qualified-id that names a
// member of an unknown specialization.
Modified: cfe/trunk/test/SemaTemplate/dependent-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-expr.cpp?rev=93514&r1=93513&r2=93514&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/dependent-expr.cpp (original)
+++ cfe/trunk/test/SemaTemplate/dependent-expr.cpp Fri Jan 15 10:21:02 2010
@@ -5,3 +5,22 @@
void Test(Iterator it) {
*(it += 1);
}
+
+namespace PR6045 {
+ template<unsigned int r>
+ class A
+ {
+ static const unsigned int member = r;
+ void f();
+ };
+
+ template<unsigned int r>
+ const unsigned int A<r>::member;
+
+ template<unsigned int r>
+ void A<r>::f()
+ {
+ unsigned k;
+ (void)(k % member);
+ }
+}
More information about the cfe-commits
mailing list