mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 00:45:28 +02:00
Bug 451091 - Make type of constexpr variable const-qualified
Change-Id: I432264fe733e27009dfc9cfbaa37631424af7d0c Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/37224 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
98ccf145c3
commit
39dce1d497
2 changed files with 12 additions and 1 deletions
|
@ -10978,4 +10978,12 @@ public class AST2CPPTests extends AST2TestBase {
|
|||
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||
isParameterSignatureEqual(sd.getDeclarators()[0], "(int&&)");
|
||||
}
|
||||
|
||||
// constexpr int waldo = 42;
|
||||
public void testConstexprVariableIsConst_451091() throws Exception {
|
||||
BindingAssertionHelper helper = getAssertionHelper();
|
||||
ICPPVariable waldo = helper.assertNonProblem("waldo");
|
||||
assertInstance(waldo.getType(), IQualifierType.class);
|
||||
assertTrue(((IQualifierType) waldo.getType()).isConst());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2243,7 +2243,10 @@ public class CPPVisitor extends ASTQueries {
|
|||
}
|
||||
|
||||
private static IType qualifyType(IType type, IASTDeclSpecifier declSpec) {
|
||||
return SemanticUtil.addQualifiers(type, declSpec.isConst(), declSpec.isVolatile(), declSpec.isRestrict());
|
||||
boolean isConst = declSpec.isConst()
|
||||
|| (declSpec instanceof ICPPASTDeclSpecifier
|
||||
&& ((ICPPASTDeclSpecifier) declSpec).isConstexpr());
|
||||
return SemanticUtil.addQualifiers(type, isConst, declSpec.isVolatile(), declSpec.isRestrict());
|
||||
}
|
||||
|
||||
private static IType createType(IType baseType, IASTDeclarator declarator) {
|
||||
|
|
Loading…
Add table
Reference in a new issue