Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2018-02-06 07:31:34 +0000
committerNathan Ridge2018-02-20 07:11:48 +0000
commit99e842bc6e0fa2c77308b6e75ee97f0843e2e924 (patch)
treeb7f5e479c068eb1d10ffc3a45a1e2c20449476ce
parentafb3ad751165f47c157f2e979fa3ce506458db1b (diff)
downloadorg.eclipse.cdt-99e842bc6e0fa2c77308b6e75ee97f0843e2e924.tar.gz
org.eclipse.cdt-99e842bc6e0fa2c77308b6e75ee97f0843e2e924.tar.xz
org.eclipse.cdt-99e842bc6e0fa2c77308b6e75ee97f0843e2e924.zip
Bug 530729 - Accept C++11 attribute specifier before parameter declaration
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java4
2 files changed, 10 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index e7c1c2b670..98a1863133 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -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];
// };
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index 4ff13c545f..8dbe4c4a68 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -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);

Back to the top