Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarco Stornelli2020-03-18 15:19:39 +0000
committerJonah Graham2020-03-20 14:38:23 +0000
commitc3346dd6cc9b6d90ed01e46db5c138fb10202c1b (patch)
treea8b52641dfe014333581c3739ec38d7558e6fe40 /core
parenta8b8573b8e37f7e667af93cc939432f1c09de4be (diff)
downloadorg.eclipse.cdt-c3346dd6cc9b6d90ed01e46db5c138fb10202c1b.tar.gz
org.eclipse.cdt-c3346dd6cc9b6d90ed01e46db5c138fb10202c1b.tar.xz
org.eclipse.cdt-c3346dd6cc9b6d90ed01e46db5c138fb10202c1b.zip
Bug 561128 - Additional fix for lambda constexpr
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java17
2 files changed, 21 insertions, 6 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java
index ed01e62a1b2..7a02be8d2b5 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/FunctionTests.java
@@ -281,4 +281,14 @@ public class FunctionTests extends TestBase {
public void testLambdaExpression_560483() throws Exception {
assertEvaluationEquals(58);
}
+
+ // //Empty header file
+
+ // constexpr int f() {
+ // return ([]() constexpr -> int {return 58;})();
+ // }
+ // constexpr int x = f();
+ public void testLambdaExpression2_560483() throws Exception {
+ assertEvaluationEquals(58);
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
index 13baf5f1f81..391a4db7bb3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
@@ -777,17 +777,22 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
}
public static ICPPExecution computeFunctionBodyExecution(IASTNode def) {
- ICPPASTFunctionDefinition fnDef = getFunctionDefinition(def);
- if (fnDef == null) {
- ICPPASTLambdaExpression lambda = ASTQueries.findAncestorWithType(def, ICPPASTLambdaExpression.class);
- if (lambda == null)
- return null;
+
+ while (def != null && !(def instanceof IASTDeclaration) && !(def instanceof ICPPASTLambdaExpression)) {
+ def = def.getParent();
+ }
+ if (def == null)
+ return null;
+
+ if (def instanceof ICPPASTLambdaExpression) {
+ ICPPASTLambdaExpression lambda = (ICPPASTLambdaExpression) def;
((ASTNode) lambda).resolvePendingAmbiguities();
if (lambda.getBody() instanceof CPPASTCompoundStatement) {
CPPASTCompoundStatement body = (CPPASTCompoundStatement) lambda.getBody();
return body.getExecution();
}
- } else {
+ } else if (def instanceof ICPPASTFunctionDefinition) {
+ ICPPASTFunctionDefinition fnDef = (ICPPASTFunctionDefinition) def;
// Make sure ambiguity resolution has been performed on the function body, even
// if it's a class method and we're still processing the class declaration.
((ASTNode) fnDef).resolvePendingAmbiguities();

Back to the top