mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 561128 - Additional fix for lambda constexpr
Change-Id: Ieee1eb4a494ec452bb5f710b2ffafd62ad798d2a
This commit is contained in:
parent
a8b8573b8e
commit
c3346dd6cc
2 changed files with 21 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
|
||||
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();
|
||||
|
|
Loading…
Add table
Reference in a new issue