From b9e712f8d02fc0140d8eeb0a5622ee51153b65b7 Mon Sep 17 00:00:00 2001 From: "Igor V. Kovalenko" Date: Fri, 17 Feb 2023 23:57:48 +0300 Subject: [PATCH] Test for binary expression with variable template args, bug 497931 Includes test case from comment 8 of bug 497931 with minor correction Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=497931 --- .../parser/tests/ast2/AST2TemplateTests.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) 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 ef554cfed68..359107fe7b1 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 @@ -11419,4 +11419,78 @@ public class AST2TemplateTests extends AST2CPPTestBase { helper.assertVariableValue("val1", 4); helper.assertVariableValue("val2", 8); } + + // template + // inline constexpr bool V = true; + // + // template bool f() { + // return V + V; + // } + public void testBinaryExpressionWithVariableTemplateVsPlusUnaryExpression() throws Exception { + parseAndCheckBindings(); + } + + // template + // inline constexpr bool V = true; + // + // template bool f() { + // return V || V; + // } + public void testBinaryExpressionWithVariableTemplate() throws Exception { + parseAndCheckBindings(); + } + + // template + // inline constexpr bool V = true; + // + // template bool f() { + // return V && V; // can be parsed as V < T > &&V + // } + public void testBinaryExpressionWithVariableTemplateAmbiguousLabelReference() throws Exception { + parseAndCheckBindings(); + } + + // template + // inline constexpr bool W = true; + // template + // inline constexpr bool X = true; + // template + // inline constexpr bool Y = true; + // template + // inline constexpr bool Z = true; + // + // template bool f() { + // return W && X && Y && Z; // can be parsed as (W) < (T) > (&&X) ... + // } + public void testBinaryExpressionWithVariableTemplateDeep() throws Exception { + parseAndCheckBindings(); + } + + // constexpr int factorial(int n) { + // return n < 2 ? 1 : n * factorial(n - 1); + // } + // + // int f(); + // + // template + // class A { + // template class Waldo { + // static void f(); + // }; + // }; + // + // template <> + // class A<120> { + // public: + // static int Waldo; + // }; + // + // int main() { + // // This requires constexpr evaluation to find that return type of factorial(5) is int + // // to decide if A::Waldo is a template + // A::Waldo<0>::f(); + // } + public void testBinaryExpressionWithVariableTemplate_bug497931_comment8() throws Exception { + parseAndCheckBindings(); + } }