From d22e72fb14a4db3c45ae4a9b4af53f71b330c0c9 Mon Sep 17 00:00:00 2001 From: John Camelon Date: Tue, 6 Apr 2004 14:37:29 +0000 Subject: [PATCH] org.eclipse.cdt.core Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=39704 Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=29060 org.eclipse.cdt.core.tests Moved testBug39704A(), testBug39704B(), testBug39704C() & testBug39704D() from ASTFailedTests to QuickParseASTTests. --- core/org.eclipse.cdt.core.tests/ChangeLog | 3 ++ .../parser/failedTests/ASTFailedTests.java | 34 ------------------- .../core/parser/tests/QuickParseASTTests.java | 26 ++++++++++++++ .../parser/ChangeLog-parser | 4 +++ .../parser/scanner/GCCScannerExtension.java | 27 ++++++++++++++- .../internal/core/parser/scanner/Scanner.java | 1 - 6 files changed, 59 insertions(+), 36 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index dd36cb27e3e..ca953350aaa 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,6 @@ +2004-04-06 John Camelon + Moved testBug39704A(), testBug39704B(), testBug39704C() & testBug39704D() from ASTFailedTests to QuickParseASTTests. + 2004-04-06 John Camelon Added ScannerTestCase::testBug47797(). diff --git a/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/ASTFailedTests.java b/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/ASTFailedTests.java index d1dca0671c7..82162d33954 100644 --- a/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/ASTFailedTests.java +++ b/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/ASTFailedTests.java @@ -186,40 +186,6 @@ public class ASTFailedTests extends BaseASTTest IASTAbstractTypeSpecifierDeclaration abs = (IASTAbstractTypeSpecifierDeclaration)assertSoleDeclaration(code.toString()); assertEquals( ((IASTClassSpecifier)abs.getTypeSpecifier()).getName(), "G" ); } - public void testBug39704A() throws Exception - { - assertCodeFailsParse("__declspec (dllimport) int foo;"); - } - - - public void testBug39704B() throws Exception - { - try - { - IASTVariable d = (IASTVariable)assertSoleDeclaration("extern int (* import) (void) __attribute__((dllimport));"); - assertEquals( d.getName(), "__attribute__"); // false assertion - } - catch( ClassCastException cce ) - { - failedAsExpected(); - } - } - public void testBug39704C() throws Exception - { - try - { - IASTFunction f = (IASTFunction)assertSoleDeclaration("int func2 (void) __attribute__((dllexport));"); - assertNotReached(); - assertEquals( f.getName(), "func2"); - } catch( ClassCastException cce ) - { - } - } - public void testBug39704D() throws Exception - { - assertCodeFailsParse("__declspec(dllexport) int func1 (int a) {}"); - } - public void testBug40422() throws Exception { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java index 1a64ff65a55..cafd99f8ce4 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java @@ -2136,4 +2136,30 @@ public class QuickParseASTTests extends BaseASTTest IASTVariable variable = (IASTVariable)parse("int ab$cd = 1;").getDeclarations().next(); assertEquals( variable.getName(), "ab$cd"); } + + + public void testBug39704A() throws Exception + { + IASTVariable foo = (IASTVariable) assertSoleDeclaration("__declspec (dllimport) int foo;"); + assertEquals( foo.getName(), "foo"); + } + + + public void testBug39704B() throws Exception + { + IASTVariable d = (IASTVariable)assertSoleDeclaration("extern int (* import) (void) __attribute__((dllimport));"); + assertEquals( d.getName(), "import"); // false assertion + } + public void testBug39704C() throws Exception + { + IASTFunction f = (IASTFunction)assertSoleDeclaration("int func2 (void) __attribute__((dllexport));"); + assertEquals( f.getName(), "func2"); + } + + public void testBug39704D() throws Exception + { + IASTFunction func1 = (IASTFunction) assertSoleDeclaration("__declspec(dllexport) int func1 (int a) {}"); + assertEquals( func1.getName(), "func1"); + } + } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser index ca9ea41e02f..d3c397df71f 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser +++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser @@ -1,3 +1,7 @@ +2004-04-06 John Camelon + Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=39704 + Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=29060 + 2004-04-06 John Camelon Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=47797 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/GCCScannerExtension.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/GCCScannerExtension.java index b29ac676601..2521b2040be 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/GCCScannerExtension.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/GCCScannerExtension.java @@ -10,17 +10,21 @@ ***********************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.IScanner; +import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ast.IASTInclusion; import org.eclipse.cdt.core.parser.extension.IScannerExtension; -import org.eclipse.cdt.internal.core.parser.util.TraceUtil; import org.eclipse.cdt.internal.core.parser.scanner.ScannerUtility.InclusionParseException; +import org.eclipse.cdt.internal.core.parser.token.Token; +import org.eclipse.cdt.internal.core.parser.util.TraceUtil; /** * @author jcamelon @@ -29,7 +33,16 @@ public class GCCScannerExtension implements IScannerExtension { private IScannerData scannerData; + private static final String __ATTRIBUTE__ = "__attribute__"; + private static final String __DECLSPEC = "__declspec"; + private static final List EMPTY_LIST = new ArrayList(); + private static final List simpleIdentifiers; + static + { + simpleIdentifiers = new ArrayList(); + simpleIdentifiers.add( new Token( IToken.tIDENTIFIER, "x")); //$NON-NLS-1 + } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.IScannerExtension#initializeMacroValue(java.lang.String) */ @@ -43,6 +56,18 @@ public class GCCScannerExtension implements IScannerExtension { * @see org.eclipse.cdt.core.parser.IScannerExtension#setupBuiltInMacros() */ public void setupBuiltInMacros(ParserLanguage language) { + + if( scannerData.getScanner().getDefinition( __ATTRIBUTE__) == null ) + { + scannerData.getScanner().addDefinition( __ATTRIBUTE__, new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiers, EMPTY_LIST, "#define __attribute__( x )", "" )); //$NON-NLS-1$ $NON-NLS-2$ + } + + if( scannerData.getScanner().getDefinition( __DECLSPEC) == null ) + { + scannerData.getScanner().addDefinition( __DECLSPEC, new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiers, EMPTY_LIST, "#define __attribute__( x )", "" )); //$NON-NLS-1$ $NON-NLS-2$ + } + + if( language == ParserLanguage.CPP ) if( scannerData.getScanner().getDefinition( IScanner.__CPLUSPLUS ) == null ) scannerData.getScanner().addDefinition( IScanner.__CPLUSPLUS, new ObjectMacroDescriptor( IScanner.__CPLUSPLUS, "1")); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java index ded0f3db5e7..3be9093baed 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java @@ -152,7 +152,6 @@ public class Scanner implements IScanner { // assert false } - TraceUtil.outputTrace(log, "Scanner constructed with the following configuration:"); //$NON-NLS-1$ TraceUtil.outputTrace(log, "\tPreprocessor definitions from IScannerInfo: "); //$NON-NLS-1$