[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] FIXED 80496 - CDT Parser does not recognize preprocessor directive '#' over macro argument
|
This patch is for the 2.0 stream only.
The 2.1/HEAD streams already have this fixed.
FIXED 80496 - CDT Parser does not recognize
preprocessor directive '#' over macro argument
Devin Steffler
IBM's Eclipse CDT
Ottawa (Palladium), Ontario, Canada
Index: parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java,v
retrieving revision 1.107.2.8
diff -u -r1.107.2.8 CompleteParseASTTest.java
--- parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java 27 Oct 2004 13:44:24 -0000 1.107.2.8
+++ parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java 8 Dec 2004 19:40:18 -0000
@@ -2140,4 +2140,12 @@
IASTParameterDeclaration blank = (IASTParameterDeclaration)parms.next();
assertEquals( ASTUtil.getType( (IASTAbstractDeclaration)blank ), "volatile int&" ); //$NON-NLS-1$
}
+
+ public void testBug80496() throws Exception
+ {
+ Writer writer = new StringWriter();
+ writer.write("int printf(const char*, ...);\n"); //$NON-NLS-1$
+ writer.write("#define PRINT_ARGUMENT(arg) printf(\"%s is the argument of this macro\",#arg)\n"); //$NON-NLS-1$
+ parse( writer.toString() );
+ }
}
Index: parser/org/eclipse/cdt/internal/core/parser/scanner2/Scanner2.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/Scanner2.java,v
retrieving revision 1.15.2.18
diff -u -r1.15.2.18 Scanner2.java
--- parser/org/eclipse/cdt/internal/core/parser/scanner2/Scanner2.java 25 Oct 2004 17:52:07 -0000 1.15.2.18
+++ parser/org/eclipse/cdt/internal/core/parser/scanner2/Scanner2.java 8 Dec 2004 19:39:57 -0000
@@ -1688,15 +1688,19 @@
while (bufferPos[bufferStackPos] + 1 < limit
&& buffer[bufferPos[bufferStackPos] + 1] != '\n') {
if( arglist != null && !skipOverNonWhiteSpace( true ) ){
- ++bufferPos[bufferStackPos];
+ ++bufferPos[bufferStackPos]; // advances us to the #
if( skipOverWhiteSpace() )
encounteredMultilineComment = true;
boolean isArg = false;
- for( int i = 0; i < arglist.length && arglist[i] != null; i++ ){
- if( CharArrayUtils.equals( buffer, bufferPos[bufferStackPos], arglist[i].length, arglist[i] ) ){
- isArg = true;
- break;
- }
+ if (bufferPos[bufferStackPos] + 1 < limit)
+ {
+ ++bufferPos[bufferStackPos]; // advances us past the # (or last whitespace)
+ for( int i = 0; i < arglist.length && arglist[i] != null; i++ ){
+ if( CharArrayUtils.equals( buffer, bufferPos[bufferStackPos], arglist[i].length, arglist[i] ) ){
+ isArg = true;
+ break;
+ }
+ }
}
if( !isArg )
handleProblem( IProblem.PREPROCESSOR_MACRO_PASTING_ERROR, bufferPos[bufferStackPos], null );