mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-07 08:15:48 +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 {
|
public void testLambdaCaptures_535196_3() throws Exception {
|
||||||
parseAndCheckBindings();
|
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);
|
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?
|
* Is the method pure virtual?
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
||||||
private boolean isConst;
|
private boolean isConst;
|
||||||
private boolean isMutable;
|
private boolean isMutable;
|
||||||
private RefQualifier refQualifier;
|
private RefQualifier refQualifier;
|
||||||
|
private boolean isConstexpr;
|
||||||
|
|
||||||
private ICPPFunctionScope scope;
|
private ICPPFunctionScope scope;
|
||||||
|
|
||||||
|
@ -78,6 +79,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
||||||
copy.isConst = isConst;
|
copy.isConst = isConst;
|
||||||
copy.isMutable = isMutable;
|
copy.isMutable = isMutable;
|
||||||
copy.refQualifier = refQualifier;
|
copy.refQualifier = refQualifier;
|
||||||
|
copy.isConstexpr = isConstexpr;
|
||||||
|
|
||||||
for (IASTParameterDeclaration param : getParameters()) {
|
for (IASTParameterDeclaration param : getParameters()) {
|
||||||
copy.addParameterDeclaration(param == null ? null : param.copy(style));
|
copy.addParameterDeclaration(param == null ? null : param.copy(style));
|
||||||
|
@ -404,4 +406,15 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
||||||
}
|
}
|
||||||
return null;
|
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
|
// cv-qualifiers
|
||||||
if (isLambdaDeclarator) {
|
if (isLambdaDeclarator) {
|
||||||
if (LT(1) == IToken.t_mutable) {
|
specloop: while (true) {
|
||||||
fc.setMutable(true);
|
switch (LT(1)) {
|
||||||
endOffset = consume().getEndOffset();
|
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 {
|
} else {
|
||||||
cvloop: while (true) {
|
cvloop: while (true) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue