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 4e2e10fdc5f..01747fbb711 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 @@ -143,7 +143,7 @@ public class AST2Tests extends AST2BaseTest { buffer.append( "int (*zzz2) (char); \n" ); //$NON-NLS-1$ buffer.append( "int ((*zzz3)) (char); \n" ); //$NON-NLS-1$ buffer.append( "int (*(zzz4)) (char); \n" ); //$NON-NLS-1$ - IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C ); //$NON-NLS-1$ + IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C ); CNameCollector col = new CNameCollector(); tu.accept(col); assertNoProblemBindings( col ); @@ -151,7 +151,7 @@ public class AST2Tests extends AST2BaseTest { protected IASTTranslationUnit parseAndCheckBindings( String code ) throws Exception { - IASTTranslationUnit tu = parse( code, ParserLanguage.C ); //$NON-NLS-1$ + IASTTranslationUnit tu = parse( code, ParserLanguage.C ); CNameCollector col = new CNameCollector(); tu.accept(col); assertNoProblemBindings( col ); @@ -1983,7 +1983,7 @@ public class AST2Tests extends AST2BaseTest { } public void testMoregetDeclarationsInAST1() throws Exception { - StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$ + StringBuffer buffer = new StringBuffer(); buffer.append("struct S {\n"); //$NON-NLS-1$ buffer.append(" int a;\n"); //$NON-NLS-1$ buffer.append(" int b;\n"); //$NON-NLS-1$ @@ -2025,7 +2025,7 @@ public class AST2Tests extends AST2BaseTest { } public void testMoregetDeclarationsInAST2() throws Exception { - StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$ + StringBuffer buffer = new StringBuffer(); buffer.append(" struct S { \n"); //$NON-NLS-1$ buffer.append(" int a; \n"); //$NON-NLS-1$ buffer.append(" int b; \n"); //$NON-NLS-1$ @@ -2061,7 +2061,7 @@ public class AST2Tests extends AST2BaseTest { } public void testMoregetDeclarationsInAST3() throws Exception { - StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$ + StringBuffer buffer = new StringBuffer(); buffer.append(" typedef struct S { \n"); //$NON-NLS-1$ buffer.append(" int a; \n"); //$NON-NLS-1$ buffer.append(" int b; \n"); //$NON-NLS-1$ @@ -2154,7 +2154,7 @@ public class AST2Tests extends AST2BaseTest { StringBuffer buffer = new StringBuffer("int f() {}\n"); //$NON-NLS-1$ buffer.append("int *f2() {}\n"); //$NON-NLS-1$ buffer.append("int (* f3())() {}\n"); //$NON-NLS-1$ - IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); //$NON-NLS-1$ + IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C); IASTFunctionDefinition def1 = (IASTFunctionDefinition) tu .getDeclarations()[0]; @@ -2525,7 +2525,7 @@ public class AST2Tests extends AST2BaseTest { } public void testBug80978() throws Exception { - StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$ + StringBuffer buffer = new StringBuffer(); buffer.append("int y ( int [ const *] );"); //$NON-NLS-1$ ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTStandardFunctionDeclarator) ((IASTSimpleDeclaration) parse( buffer.toString(), ParserLanguage.C).getDeclarations()[0]) @@ -3517,4 +3517,13 @@ public class AST2Tests extends AST2BaseTest { binding= params[0].getDeclarator().getName().resolveBinding(); assertEquals(7, tu.getReferences(binding).length); } + + // #define MAC(x) x + // void func() { + // MAC("); + // } + public void testBug179383() throws ParserException, IOException { + StringBuffer sb= getContents(1)[0]; + parse(sb.toString(), ParserLanguage.C, false, false); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/AbstractParserLogService.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/AbstractParserLogService.java index 186ed05da27..43ce3b1dfe4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/AbstractParserLogService.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/AbstractParserLogService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,12 +23,12 @@ public abstract class AbstractParserLogService implements IParserLogService { return false; } - boolean traceExceptions() { + public boolean isTracingExceptions() { return false; } public void traceException(Throwable th) { - if (traceExceptions()) { + if (isTracingExceptions()) { th.printStackTrace(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java index 27e35464891..c4bed1e9fe6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java @@ -3165,6 +3165,11 @@ abstract class BaseScanner implements IScanner { } else argend = skipOverMacroArg(); + // correct argend when reaching limit, (bug 179383) + if (argend==limit) { + argend--; + } + char[] arg = EMPTY_CHAR_ARRAY; int arglen = argend - argstart + 1; if (arglen > 0) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java index 626f828efd4..ce417aab16e 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/parser/ParserLogService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2006 IBM Corporation and others. + * Copyright (c) 2002, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -64,4 +64,8 @@ public class ParserLogService extends AbstractParserLogService return ( CCorePlugin.getDefault().isDebugging() && Util.isActive( topic ) ); } + + public boolean isTracingExceptions() { + return fIsTracingExceptions; + } }