mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 506170 - Evaluation of dependent conditional expression
Change-Id: I59355bb40e84662554be76929ba9f9618aec7dba
This commit is contained in:
parent
b6d218a652
commit
8244bcd33d
2 changed files with 20 additions and 1 deletions
|
@ -9293,6 +9293,23 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
assertConstantValue(0, waldo);
|
assertConstantValue(0, waldo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// struct traits {
|
||||||
|
// static constexpr int Flags = 1;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template <typename T>
|
||||||
|
// struct S {
|
||||||
|
// static constexpr int a = traits<T>::Flags;
|
||||||
|
// static constexpr int b = a ? 42 : 0;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// constexpr int waldo = S<int>::b;
|
||||||
|
public void testDependentConditionalExpression_506170() throws Exception {
|
||||||
|
BindingAssertionHelper helper = getAssertionHelper();
|
||||||
|
helper.assertVariableValue("waldo", 42);
|
||||||
|
}
|
||||||
|
|
||||||
// template <typename>
|
// template <typename>
|
||||||
// struct C {
|
// struct C {
|
||||||
// friend bool operator==(C, C);
|
// friend bool operator==(C, C);
|
||||||
|
|
|
@ -282,8 +282,10 @@ public class ValueFactory {
|
||||||
if (exp instanceof IASTConditionalExpression) {
|
if (exp instanceof IASTConditionalExpression) {
|
||||||
IASTConditionalExpression cexpr= (IASTConditionalExpression) exp;
|
IASTConditionalExpression cexpr= (IASTConditionalExpression) exp;
|
||||||
IValue v= evaluate(cexpr.getLogicalConditionExpression());
|
IValue v= evaluate(cexpr.getLogicalConditionExpression());
|
||||||
if (isInvalidValue(v) || v.numberValue() == null)
|
if (isInvalidValue(v))
|
||||||
return v;
|
return v;
|
||||||
|
if (isDeferredValue(v))
|
||||||
|
return null; // the value will be computed using the evaluation
|
||||||
if (v.numberValue().longValue() == 0) {
|
if (v.numberValue().longValue() == 0) {
|
||||||
return evaluate(cexpr.getNegativeResultExpression());
|
return evaluate(cexpr.getNegativeResultExpression());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue