From c5c666a8b6038e126ecdeefda6b06119c2c71694 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 27 Jul 2007 14:08:46 +0000 Subject: [PATCH] Fix and testcase for 191450, __attribute__ in-between pointer-operators. --- .../cdt/core/parser/tests/ast2/AST2CPPTests.java | 3 --- .../cdt/core/parser/tests/ast2/AST2Tests.java | 15 ++++++++++++--- .../parser/tests/ast2/CompleteParser2Tests.java | 13 ++++++------- .../core/dom/parser/c/GNUCSourceParser.java | 13 ++++++------- .../core/dom/parser/cpp/GNUCPPSourceParser.java | 5 ++--- 5 files changed, 26 insertions(+), 23 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 4ac2331ac42..a5a89050180 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 @@ -5482,9 +5482,6 @@ public class AST2CPPTests extends AST2BaseTest { assertFalse(binding instanceof IProblemBinding); } - - - // #define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) // #define _GLIBCXX_BEGIN_NAMESPACE(X) namespace X _GLIBCXX_VISIBILITY(default) { // _GLIBCXX_BEGIN_NAMESPACE(std) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 0f7b488b1d4..91d4a97745b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Andrew Ferguson (Symbian) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; @@ -3924,4 +3924,13 @@ public class AST2Tests extends AST2BaseTest { parse( content, ParserLanguage.CPP); parse( content, ParserLanguage.C); } + + // void ( __attribute__((__stdcall__))* foo1) (int); + // void ( * __attribute__((__stdcall__)) foo2) (int); + // void ( * __attribute__((__stdcall__))* foo3) (int); + public void testBug191450_attributesInBetweenPointers() throws Exception { + StringBuffer buffer = getContents(1)[0]; + parse( buffer.toString(), ParserLanguage.CPP, true, true ); + parse( buffer.toString(), ParserLanguage.C, true, true ); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java index 8f0708bc786..bb98b30c266 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; @@ -2206,11 +2206,10 @@ public class CompleteParser2Tests extends BaseTestCase { writer.write( "int func3 (void) __attribute__((id,id (3)));\n" ); //$NON-NLS-1$ writer.write( "int func4 (void) __attribute__((id,id (1+2)));\n" ); //$NON-NLS-1$ writer.write( "void (****f1)(void) __attribute__((noreturn));\n" ); //$NON-NLS-1$ -/* not yet supported by the GCC compiler: - * writer.write( "void (__attribute__((noreturn)) ****f2) (void);\n" ); //$NON-NLS-1$ - * writer.write( "char *__attribute__((aligned(8))) *f3;\n" ); //$NON-NLS-1$ - * writer.write( "char * __attribute__((aligned(8))) * f3;\n" ); //$NON-NLS-1$ -*/ writer.write( "void fatal1 () __attribute__ ((noreturn));\n" ); //$NON-NLS-1$ + writer.write( "void (__attribute__((noreturn)) ****f2) (void);\n" ); //$NON-NLS-1$ + writer.write( "char *__attribute__((aligned(8))) *f3;\n" ); //$NON-NLS-1$ + writer.write( "char * __attribute__((aligned(8))) * f3;\n" ); //$NON-NLS-1$ + writer.write( "void fatal1 () __attribute__ ((noreturn));\n" ); //$NON-NLS-1$ writer.write( "int square1 (int) __attribute__ ((pure));\n" ); //$NON-NLS-1$ writer.write( "extern int\n" ); //$NON-NLS-1$ writer.write( "my_printf1 (void *my_object, const char *my_format, ...)\n" ); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java index 0285011f58c..439027bfa65 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Ed Swartz (Nokia) + * IBM Rational Software - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Ed Swartz (Nokia) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -1342,10 +1342,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { protected void consumePointerOperators(List pointerOps) throws EndOfFileException, BacktrackException { for (;;) { -// having __attribute__ inbetween pointers is not yet supported by the GCC compiler -// if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ is after a * -// __attribute__(); - + // __attribute__ in-between pointers + __attribute_decl_seq(supportAttributeSpecifiers, false); + IToken mark = mark(); IToken last = null; 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 971ceda73d9..2b91a5c01f7 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 @@ -542,9 +542,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { throws EndOfFileException, BacktrackException { for (;;) { -// having __attribute__ inbetween pointers is not yet supported by the GCC compiler -// if (LT(1) == IGCCToken.t__attribute__ && supportAttributeSpecifiers) // if __attribute__ is after a * -// __attribute__(); + // __attribute__ in-between pointers + __attribute_decl_seq(supportAttributeSpecifiers, false); if (LT(1) == IToken.tAMPER) { int length = LA(1).getEndOffset() - LA(1).getOffset();