From 039e2619d819eeff5b92b53cb86799f7e0ca675a Mon Sep 17 00:00:00 2001 From: Thomas Corbat Date: Wed, 12 Mar 2014 08:35:41 +0100 Subject: [PATCH] Bug 413615 - GCC __attribute__ produces syntax error after "override" Added test and implementation of recognizing GCC attributes after override. Change-Id: I0a6661c7be2b921658240ccebba6fbcb24780f20 Reviewed-on: https://git.eclipse.org/r/23231 Reviewed-by: Thomas Corbat IP-Clean: Thomas Corbat Tested-by: Thomas Corbat --- .../cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java | 8 ++++++++ .../internal/core/dom/parser/cpp/GNUCPPSourceParser.java | 2 ++ 2 files changed, 10 insertions(+) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java index ce0adf4f27f..ad6089ffa2a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java @@ -491,4 +491,12 @@ public class AST2CPPAttributeTests extends AST2TestBase { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); checkAttributeRelations(getAttributeSpecifiers(tu), IASTDeclarator.class); } + + // struct S { + // void foo() override __attribute__((attr)); + // }; + public void testGCCAttributeAfterOverride_bug413615() throws Exception { + IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true); + checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDeclarator.class); + } } 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 261c5d36828..d098371ce4a 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 @@ -3559,6 +3559,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { // For member functions we need to consider virtual specifiers and pure-virtual syntax. if (option == DeclarationOptions.CPP_MEMBER) { optionalVirtSpecifierSeq((ICPPASTFunctionDeclarator) typeRelevantDtor); + List attributeSpecifiers = __attribute_decl_seq(supportAttributeSpecifiers, false); + addAttributeSpecifiers(attributeSpecifiers, dtor); int lt1 = LTcatchEOF(1); if (lt1 == IToken.tASSIGN && LTcatchEOF(2) == IToken.tINTEGER) { consume();