mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 14:25:37 +02:00
Bug 560483 - Add support for c++17 constexpr lambda expressions
Change-Id: Ic64ef646944c9d1b6f606f3b11f90ffed65ea95e
This commit is contained in:
parent
bcb955a321
commit
f150522ad4
4 changed files with 46 additions and 3 deletions
|
@ -50,4 +50,12 @@ public class LambdaExpressionTests extends AST2CPPTestBase {
|
|||
public void testLambdaCaptures_535196_3() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
//int main() {
|
||||
// auto f = []() constexpr {return 2;};
|
||||
// return 0;
|
||||
//}
|
||||
public void testLambdaConstexpr_560483() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,6 +101,18 @@ public interface ICPPASTFunctionDeclarator
|
|||
*/
|
||||
public void setMutable(boolean value);
|
||||
|
||||
/**
|
||||
* When used as a lambda declarator, it can be constexpr.
|
||||
* @since 6.11
|
||||
*/
|
||||
public boolean isConstexpr();
|
||||
|
||||
/**
|
||||
* When used as a lambda declarator, it can be constexpr.
|
||||
* @since 6.11
|
||||
*/
|
||||
public void setConstexpr(boolean value);
|
||||
|
||||
/**
|
||||
* Is the method pure virtual?
|
||||
*/
|
||||
|
|
|
@ -54,6 +54,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
|||
private boolean isConst;
|
||||
private boolean isMutable;
|
||||
private RefQualifier refQualifier;
|
||||
private boolean isConstexpr;
|
||||
|
||||
private ICPPFunctionScope scope;
|
||||
|
||||
|
@ -78,6 +79,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
|||
copy.isConst = isConst;
|
||||
copy.isMutable = isMutable;
|
||||
copy.refQualifier = refQualifier;
|
||||
copy.isConstexpr = isConstexpr;
|
||||
|
||||
for (IASTParameterDeclaration param : getParameters()) {
|
||||
copy.addParameterDeclaration(param == null ? null : param.copy(style));
|
||||
|
@ -404,4 +406,15 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConstexpr() {
|
||||
return isConstexpr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConstexpr(boolean value) {
|
||||
assertNotFrozen();
|
||||
this.isConstexpr = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4806,9 +4806,19 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
// cv-qualifiers
|
||||
if (isLambdaDeclarator) {
|
||||
if (LT(1) == IToken.t_mutable) {
|
||||
fc.setMutable(true);
|
||||
endOffset = consume().getEndOffset();
|
||||
specloop: while (true) {
|
||||
switch (LT(1)) {
|
||||
case IToken.t_mutable:
|
||||
fc.setMutable(true);
|
||||
endOffset = consume().getEndOffset();
|
||||
break;
|
||||
case IToken.t_constexpr:
|
||||
fc.setConstexpr(true);
|
||||
endOffset = consume().getEndOffset();
|
||||
break;
|
||||
default:
|
||||
break specloop;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cvloop: while (true) {
|
||||
|
|
Loading…
Add table
Reference in a new issue