1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-10 18:45:26 +02:00

Bug 530729 - Accept C++11 attribute specifier before parameter declaration

Change-Id: I425d1b351c10976392ecdf1e4b33f486938e0a04
This commit is contained in:
Nathan Ridge 2018-02-06 02:31:34 -05:00
parent afb3ad7511
commit 99e842bc6e
2 changed files with 10 additions and 0 deletions

View file

@ -12552,6 +12552,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */);
}
// void foo([[maybe_unused]] int a);
public void testCxx11AttributeBeforeParameterDeclaration_530729() throws Exception {
parseAndCheckBindings();
}
// struct CType {
// char m_Array[4];
// };

View file

@ -3062,6 +3062,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected ICPPASTParameterDeclaration parameterDeclaration() throws BacktrackException, EndOfFileException {
final int startOffset= LA(1).getOffset();
List<IASTAttributeSpecifier> attributes = attributeSpecifierSeq();
if (LT(1) == IToken.tLBRACKET && supportParameterInfoBlock) {
skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET, 0);
}
@ -3076,6 +3078,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
declSpec= lie.fDeclSpec;
declarator= addInitializer(lie, DeclarationOptions.PARAMETER);
}
addAttributeSpecifiers(attributes, (ICPPASTDeclSpecifier) declSpec);
final ICPPASTParameterDeclaration parm = getNodeFactory().newParameterDeclaration(declSpec, declarator);
final int endOffset = figureEndOffset(declSpec, declarator);