diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 78245d1ce22..46283bd5219 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -9292,6 +9292,23 @@ public class AST2TemplateTests extends AST2TestBase { ICPPVariable waldo = helper.assertNonProblem("waldo"); assertConstantValue(0, waldo); } + + // template + // struct traits { + // static constexpr int Flags = 1; + // }; + // + // template + // struct S { + // static constexpr int a = traits::Flags; + // static constexpr int b = a ? 42 : 0; + // }; + // + // constexpr int waldo = S::b; + public void testDependentConditionalExpression_506170() throws Exception { + BindingAssertionHelper helper = getAssertionHelper(); + helper.assertVariableValue("waldo", 42); + } // template // struct C { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java index 672970714e2..3ef448f40c6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ValueFactory.java @@ -282,8 +282,10 @@ public class ValueFactory { if (exp instanceof IASTConditionalExpression) { IASTConditionalExpression cexpr= (IASTConditionalExpression) exp; IValue v= evaluate(cexpr.getLogicalConditionExpression()); - if (isInvalidValue(v) || v.numberValue() == null) + if (isInvalidValue(v)) return v; + if (isDeferredValue(v)) + return null; // the value will be computed using the evaluation if (v.numberValue().longValue() == 0) { return evaluate(cexpr.getNegativeResultExpression()); }