mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
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.
This commit is contained in:
parent
3a5e182ba9
commit
d22e72fb14
6 changed files with 59 additions and 36 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2004-04-06 John Camelon
|
||||||
|
Moved testBug39704A(), testBug39704B(), testBug39704C() & testBug39704D() from ASTFailedTests to QuickParseASTTests.
|
||||||
|
|
||||||
2004-04-06 John Camelon
|
2004-04-06 John Camelon
|
||||||
Added ScannerTestCase::testBug47797().
|
Added ScannerTestCase::testBug47797().
|
||||||
|
|
||||||
|
|
|
@ -186,40 +186,6 @@ public class ASTFailedTests extends BaseASTTest
|
||||||
IASTAbstractTypeSpecifierDeclaration abs = (IASTAbstractTypeSpecifierDeclaration)assertSoleDeclaration(code.toString());
|
IASTAbstractTypeSpecifierDeclaration abs = (IASTAbstractTypeSpecifierDeclaration)assertSoleDeclaration(code.toString());
|
||||||
assertEquals( ((IASTClassSpecifier)abs.getTypeSpecifier()).getName(), "G" );
|
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 {
|
public void testBug40422() throws Exception {
|
||||||
|
|
|
@ -2136,4 +2136,30 @@ public class QuickParseASTTests extends BaseASTTest
|
||||||
IASTVariable variable = (IASTVariable)parse("int ab$cd = 1;").getDeclarations().next();
|
IASTVariable variable = (IASTVariable)parse("int ab$cd = 1;").getDeclarations().next();
|
||||||
assertEquals( variable.getName(), "ab$cd");
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -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
|
2004-04-06 John Camelon
|
||||||
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=47797
|
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=47797
|
||||||
|
|
||||||
|
|
|
@ -10,17 +10,21 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
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.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||||
import org.eclipse.cdt.core.parser.extension.IScannerExtension;
|
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.scanner.ScannerUtility.InclusionParseException;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.token.Token;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -29,7 +33,16 @@ public class GCCScannerExtension implements IScannerExtension {
|
||||||
|
|
||||||
|
|
||||||
private IScannerData scannerData;
|
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)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.IScannerExtension#initializeMacroValue(java.lang.String)
|
* @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()
|
* @see org.eclipse.cdt.core.parser.IScannerExtension#setupBuiltInMacros()
|
||||||
*/
|
*/
|
||||||
public void setupBuiltInMacros(ParserLanguage language) {
|
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( language == ParserLanguage.CPP )
|
||||||
if( scannerData.getScanner().getDefinition( IScanner.__CPLUSPLUS ) == null )
|
if( scannerData.getScanner().getDefinition( IScanner.__CPLUSPLUS ) == null )
|
||||||
scannerData.getScanner().addDefinition( IScanner.__CPLUSPLUS, new ObjectMacroDescriptor( IScanner.__CPLUSPLUS, "1")); //$NON-NLS-1$
|
scannerData.getScanner().addDefinition( IScanner.__CPLUSPLUS, new ObjectMacroDescriptor( IScanner.__CPLUSPLUS, "1")); //$NON-NLS-1$
|
||||||
|
|
|
@ -152,7 +152,6 @@ public class Scanner implements IScanner {
|
||||||
// assert false
|
// assert false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TraceUtil.outputTrace(log, "Scanner constructed with the following configuration:"); //$NON-NLS-1$
|
TraceUtil.outputTrace(log, "Scanner constructed with the following configuration:"); //$NON-NLS-1$
|
||||||
TraceUtil.outputTrace(log, "\tPreprocessor definitions from IScannerInfo: "); //$NON-NLS-1$
|
TraceUtil.outputTrace(log, "\tPreprocessor definitions from IScannerInfo: "); //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue