From: Eli Friedman Date: Thu, 11 Jun 2009 01:11:20 +0000 (+0000) Subject: Make sure to calculate value-dependence correctly when deal with ICEs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c149412d3adfc28ce1f1c0cf6d3701f9491adaf0;p=clang Make sure to calculate value-dependence correctly when deal with ICEs. (Actually, this isn't precisely correct, but it doesn't make sense to query whether an expression that isn't an ICE is value-dependent anyway.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73179 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index da32d4ec10..1abd5fb302 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1177,7 +1177,12 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, ValueDependent = true; // - a constant with integral or enumeration type and is // initialized with an expression that is value-dependent - // (FIXME!). + else if (const VarDecl *Dcl = dyn_cast(VD)) { + if (Dcl->getType().getCVRQualifiers() == QualType::Const && + Dcl->getInit()) { + ValueDependent = Dcl->getInit()->isValueDependent(); + } + } } return Owned(BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(), Loc, diff --git a/test/SemaTemplate/instantiate-declref-ice.cpp b/test/SemaTemplate/instantiate-declref-ice.cpp new file mode 100644 index 0000000000..21ee872027 --- /dev/null +++ b/test/SemaTemplate/instantiate-declref-ice.cpp @@ -0,0 +1,7 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +template struct x { + static const int j = i; + x* y; +}; +