Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Vogt2019-04-04 20:36:40 +0000
committerNathan Ridge2019-04-19 21:39:30 +0000
commit11a14b7ed3594b61559ed1b62e3080ff1fb04c72 (patch)
tree1afe910b1fd5281844d3946d6cf42111fa2ee371 /core/org.eclipse.cdt.core.tests
parent480af1ddb10a8b07466809f6ffb175180011a15c (diff)
downloadorg.eclipse.cdt-11a14b7ed3594b61559ed1b62e3080ff1fb04c72.tar.gz
org.eclipse.cdt-11a14b7ed3594b61559ed1b62e3080ff1fb04c72.tar.xz
org.eclipse.cdt-11a14b7ed3594b61559ed1b62e3080ff1fb04c72.zip
Bug 545756 - Improve EvalBinding.isConstantExpression()
Previously, all variables with an initial value (even non-const) were treated as constant expressions, now only constexpr variables, static const members and global const variables are treated as constant expression. Change-Id: I2acb4033a1f75110302ea25640afb070d025ec2b Signed-off-by: Hannes Vogt <hannes@havogt.de>
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java12
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java16
2 files changed, 28 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index fc1f30c02c7..f89cfcd5470 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -13031,6 +13031,18 @@ public class AST2CPPTests extends AST2CPPTestBase {
parseAndCheckImplicitNameBindings();
}
+ // struct A {
+ // int x;
+ // };
+ //
+ // template <typename T>
+ // struct B {
+ // A a{sizeof(T)};
+ // };
+ public void testAggregateInitNoNarrowingConversionInDependentConstContext_545756() throws Exception {
+ parseAndCheckImplicitNameBindings();
+ }
+
// struct type{
// int a;
// };
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 1323628a656..c53ccaa951c 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
@@ -11282,4 +11282,20 @@ public class AST2TemplateTests extends AST2CPPTestBase {
helper.assertVariableValue("val1", 42);
helper.assertVariableValue("val2", 43);
}
+
+ // template <typename T>
+ // constexpr T id(T a) {
+ // return a;
+ // }
+ //
+ // template <int> struct Waldo {using type = int;};
+ //
+ // const int forty_two = 42;
+ // using const_int_ref = int const&;
+ // const_int_ref ref_forty_two = forty_two;
+ //
+ // Waldo<id(ref_forty_two)>::type a;
+ public void testGlobalConstWorksAsConstExpression_545756() throws Exception {
+ parseAndCheckBindings();
+ }
}

Back to the top