diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index b589c5494db..a9083860a41 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,6 +1,10 @@ 2003-07-25 Bogdan Gheorghe Added new indexer test for refs +2003-07-25 Victor Mozgin + Moved testBug39553() from ASTFailedTests.java to QuickParseASTTests.java. + Fixed IIncludeTest.h and IIncludeTests.java with #include macro tests. + 2003-07-24 John Camelon Updated CompleteParseASTTests for Method/Field updates. Fixed TortureTest's parser mode switch (was always QuickParsing). 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 a4006397ef9..b1d21115788 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 @@ -145,11 +145,6 @@ public class ASTFailedTests extends BaseASTTest assertEquals( variable.getName(), "id"); } - public void testBug39553() throws Exception - { - parse("#define COMP_INC \"foobar.h\" \n" + "#include COMP_INC"); - assertFalse( quickParseCallback.getInclusions().hasNext() ); - } public void testBug39554() throws Exception { assertCodeFailsParse("_Pragma(\"foobar\")"); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java index 156bb121cb1..e09ea53c5ca 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java @@ -76,11 +76,11 @@ public class IIncludeTests extends IntegratedCModelTest { new String("whitespace_before_hash"), new String("resync_after_bad_parse_1"), new String("resync_after_bad_parse_2"), - new String("one"), // C-spec does not allow this, but that's OK for our present purposes + new String("onetwothree"), // C-spec does not allow this, but that's OK for our present purposes new String("resync_after_bad_parse_3"), new String("invalid.h"), // C-spec does not allow this, but that's OK for our present purposes - // TODO: expect new String("MYINCFILE"), - // TODO: expect new String("xstr(INCFILE(2)).h") + new String("myInclude1.h"), + new String("vers2.h") }; assertEquals( getIncludeNameList.length, theIncludes.length ); for( int i=0; i" ); + } + + return; + } + + // This should throw EOF + t = helperScanner.nextToken(false); + + if (throwExceptionOnBadPreprocessorSyntax) { + throw new ScannerException( "Encountered ill-formed #include" ); + } + + return; + + } else if (throwExceptionOnBadPreprocessorSyntax) { + throw new ScannerException( "Encountered ill-formed #include" ); + } + } + catch( EndOfFile eof ) + { + // good + } + + } else if (throwExceptionOnBadPreprocessorSyntax) { + throw new ScannerException( "Encountered ill-formed #include" ); } - + String f = fileName.toString(); - offset = contextStack.getCurrentContext().getOffset() - f.length() - 1; // -1 for the end quote if( mode == ParserMode.QUICK_PARSE ) { if( requestor != null ) { IASTInclusion i = astFactory.createInclusion( f, "", !useIncludePath, beginningOffset, - contextStack.getCurrentContext().getOffset(), offset ); + endOffset, startOffset ); i.enterScope( requestor ); i.exitScope( requestor ); } } else - handleInclusion(f.trim(), useIncludePath, offset, beginningOffset, contextStack.getCurrentContext().getOffset() ); - + handleInclusion(f.trim(), useIncludePath, startOffset, beginningOffset, endOffset); } protected void poundDefine(int beginning) throws ScannerException, EndOfFile { @@ -2097,7 +2138,7 @@ public class Scanner implements IScanner { protected Vector getMacroParameters (String params, boolean forStringizing) throws ScannerException { - IScanner tokenizer = ParserFactory.createScanner(new StringReader(params), TEXT, new ScannerInfo( definitions, originalConfig.getIncludePaths() ), mode, new NullSourceElementRequestor(), problemReporter, translationResult ); + Scanner tokenizer = new Scanner(new StringReader(params), TEXT, new ScannerInfo( definitions, originalConfig.getIncludePaths() ), problemReporter, translationResult, new NullSourceElementRequestor(), mode); Vector parameterValues = new Vector(); Token t = null; String str = new String(); @@ -2106,6 +2147,12 @@ public class Scanner implements IScanner { try { while (true) { + int c = tokenizer.getChar(); + if ((c != ' ') && (c != '\t') && (c != '\r') && (c != '\n')) { + space = false; + } + if (c != NOCHAR) tokenizer.ungetChar(c); + t = (Token)(forStringizing ? tokenizer.nextTokenForStringizing() : tokenizer.nextToken(false)); if (t.type == IToken.tLPAREN) { nParen++; @@ -2261,7 +2308,7 @@ public class Scanner implements IScanner { if( t.getType() != tPOUNDPOUND && ! pastingNext ) if (i < (numberOfTokens-1)) // Do not append to the last one - buffer.append( " " ); + buffer.append( " " ); } String finalString = buffer.toString(); contextStack.updateContext(