mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 17:25:38 +02:00
Fix for 179383, infinite loop in scanner.
This commit is contained in:
parent
bb895064cf
commit
4a8670a767
4 changed files with 29 additions and 11 deletions
|
@ -143,7 +143,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
buffer.append( "int (*zzz2) (char); \n" ); //$NON-NLS-1$
|
buffer.append( "int (*zzz2) (char); \n" ); //$NON-NLS-1$
|
||||||
buffer.append( "int ((*zzz3)) (char); \n" ); //$NON-NLS-1$
|
buffer.append( "int ((*zzz3)) (char); \n" ); //$NON-NLS-1$
|
||||||
buffer.append( "int (*(zzz4)) (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();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
assertNoProblemBindings( col );
|
assertNoProblemBindings( col );
|
||||||
|
@ -151,7 +151,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
protected IASTTranslationUnit parseAndCheckBindings( String code ) throws Exception
|
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();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
assertNoProblemBindings( col );
|
assertNoProblemBindings( col );
|
||||||
|
@ -1983,7 +1983,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMoregetDeclarationsInAST1() throws Exception {
|
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("struct S {\n"); //$NON-NLS-1$
|
||||||
buffer.append(" int a;\n"); //$NON-NLS-1$
|
buffer.append(" int a;\n"); //$NON-NLS-1$
|
||||||
buffer.append(" int b;\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 {
|
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(" struct S { \n"); //$NON-NLS-1$
|
||||||
buffer.append(" int a; \n"); //$NON-NLS-1$
|
buffer.append(" int a; \n"); //$NON-NLS-1$
|
||||||
buffer.append(" int b; \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 {
|
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(" typedef struct S { \n"); //$NON-NLS-1$
|
||||||
buffer.append(" int a; \n"); //$NON-NLS-1$
|
buffer.append(" int a; \n"); //$NON-NLS-1$
|
||||||
buffer.append(" int b; \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$
|
StringBuffer buffer = new StringBuffer("int f() {}\n"); //$NON-NLS-1$
|
||||||
buffer.append("int *f2() {}\n"); //$NON-NLS-1$
|
buffer.append("int *f2() {}\n"); //$NON-NLS-1$
|
||||||
buffer.append("int (* f3())() {}\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
|
IASTFunctionDefinition def1 = (IASTFunctionDefinition) tu
|
||||||
.getDeclarations()[0];
|
.getDeclarations()[0];
|
||||||
|
@ -2525,7 +2525,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug80978() throws Exception {
|
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$
|
buffer.append("int y ( int [ const *] );"); //$NON-NLS-1$
|
||||||
ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTStandardFunctionDeclarator) ((IASTSimpleDeclaration) parse(
|
ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTStandardFunctionDeclarator) ((IASTSimpleDeclaration) parse(
|
||||||
buffer.toString(), ParserLanguage.C).getDeclarations()[0])
|
buffer.toString(), ParserLanguage.C).getDeclarations()[0])
|
||||||
|
@ -3517,4 +3517,13 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
binding= params[0].getDeclarator().getName().resolveBinding();
|
binding= params[0].getDeclarator().getName().resolveBinding();
|
||||||
assertEquals(7, tu.getReferences(binding).length);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -23,12 +23,12 @@ public abstract class AbstractParserLogService implements IParserLogService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean traceExceptions() {
|
public boolean isTracingExceptions() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void traceException(Throwable th) {
|
public void traceException(Throwable th) {
|
||||||
if (traceExceptions()) {
|
if (isTracingExceptions()) {
|
||||||
th.printStackTrace();
|
th.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3165,6 +3165,11 @@ abstract class BaseScanner implements IScanner {
|
||||||
} else
|
} else
|
||||||
argend = skipOverMacroArg();
|
argend = skipOverMacroArg();
|
||||||
|
|
||||||
|
// correct argend when reaching limit, (bug 179383)
|
||||||
|
if (argend==limit) {
|
||||||
|
argend--;
|
||||||
|
}
|
||||||
|
|
||||||
char[] arg = EMPTY_CHAR_ARRAY;
|
char[] arg = EMPTY_CHAR_ARRAY;
|
||||||
int arglen = argend - argstart + 1;
|
int arglen = argend - argstart + 1;
|
||||||
if (arglen > 0) {
|
if (arglen > 0) {
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -64,4 +64,8 @@ public class ParserLogService extends AbstractParserLogService
|
||||||
|
|
||||||
return ( CCorePlugin.getDefault().isDebugging() && Util.isActive( topic ) );
|
return ( CCorePlugin.getDefault().isDebugging() && Util.isActive( topic ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTracingExceptions() {
|
||||||
|
return fIsTracingExceptions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue