mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 12:45:41 +02:00
Fix & testcase for 192639, AssertionFailedError in parser.
This commit is contained in:
parent
1d64d99f2c
commit
5f0a6852c9
2 changed files with 23 additions and 7 deletions
|
@ -113,6 +113,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testBug75189() throws Exception {
|
public void testBug75189() throws Exception {
|
||||||
parseAndCheckBindings( "struct A{};\n typedef int (*F) (struct A*);" ); //$NON-NLS-1$
|
parseAndCheckBindings( "struct A{};\n typedef int (*F) (struct A*);" ); //$NON-NLS-1$
|
||||||
parseAndCheckBindings( "struct A{};\n typedef int (*F) (A*);", ParserLanguage.CPP ); //$NON-NLS-1$
|
parseAndCheckBindings( "struct A{};\n typedef int (*F) (A*);", ParserLanguage.CPP ); //$NON-NLS-1$
|
||||||
|
@ -3867,4 +3868,14 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertInstance(col.getName(13).resolveBinding(), IProblemBinding.class);
|
assertInstance(col.getName(13).resolveBinding(), IProblemBinding.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /* a comment */
|
||||||
|
// #define INVALID(a, b) ## a ## b
|
||||||
|
// INVALID(1, 2)
|
||||||
|
//
|
||||||
|
public void test192639() throws Exception {
|
||||||
|
StringBuffer buffer = getContents(1)[0];
|
||||||
|
parse( buffer.toString(), ParserLanguage.CPP, false, false, true );
|
||||||
|
parse( buffer.toString(), ParserLanguage.C, false, false, true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3575,7 +3575,7 @@ abstract class BaseScanner implements IScanner {
|
||||||
char[] prevArg = null;
|
char[] prevArg = null;
|
||||||
int prevArgStart = -1;
|
int prevArgStart = -1;
|
||||||
int prevArgLength = -1;
|
int prevArgLength = -1;
|
||||||
int prevArgTarget = -1;
|
int prevArgTarget = 0;
|
||||||
|
|
||||||
int limit = expansion.length;
|
int limit = expansion.length;
|
||||||
|
|
||||||
|
@ -3628,9 +3628,15 @@ abstract class BaseScanner implements IScanner {
|
||||||
// copy what we haven't so far
|
// copy what we haven't so far
|
||||||
if (++lastcopy < idstart) {
|
if (++lastcopy < idstart) {
|
||||||
int n = idstart - lastcopy;
|
int n = idstart - lastcopy;
|
||||||
if (result != null)
|
if (result != null) {
|
||||||
|
// the outpos may be set back when prevConcat is true, so make sure we
|
||||||
|
// stay in bounds.
|
||||||
|
if (prevConcat && outpos+n > result.length) {
|
||||||
|
n= result.length- outpos;
|
||||||
|
}
|
||||||
System.arraycopy(expansion, lastcopy, result,
|
System.arraycopy(expansion, lastcopy, result,
|
||||||
outpos, n);
|
outpos, n);
|
||||||
|
}
|
||||||
outpos += n;
|
outpos += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4257,14 +4263,14 @@ abstract class BaseScanner implements IScanner {
|
||||||
}
|
}
|
||||||
protected IToken scanComment() {
|
protected IToken scanComment() {
|
||||||
char[] buffer = bufferStack[bufferStackPos];
|
char[] buffer = bufferStack[bufferStackPos];
|
||||||
int limit = bufferLimit[bufferStackPos];
|
final int limit = bufferLimit[bufferStackPos];
|
||||||
|
|
||||||
int pos = bufferPos[bufferStackPos];
|
int pos = bufferPos[bufferStackPos];
|
||||||
if (pos + 1 < limit) {
|
if (pos + 1 < limit) {
|
||||||
if (buffer[pos + 1] == '/') {
|
if (buffer[pos + 1] == '/') {
|
||||||
// C++ comment
|
// C++ comment
|
||||||
int commentLength = 0;
|
int commentLength = 0;
|
||||||
while (++bufferPos[bufferStackPos] < bufferLimit[bufferStackPos]) {
|
while (++bufferPos[bufferStackPos] < limit) {
|
||||||
if (buffer[bufferPos[bufferStackPos]] == '\n'||buffer[bufferPos[bufferStackPos]] == '\r') {
|
if (buffer[bufferPos[bufferStackPos]] == '\n'||buffer[bufferPos[bufferStackPos]] == '\r') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4277,10 +4283,9 @@ abstract class BaseScanner implements IScanner {
|
||||||
} else if (buffer[pos + 1] == '*') {
|
} else if (buffer[pos + 1] == '*') {
|
||||||
// C comment, find closing */
|
// C comment, find closing */
|
||||||
int start = pos;
|
int start = pos;
|
||||||
for (bufferPos[bufferStackPos] += 2; bufferPos[bufferStackPos] < limit; ++bufferPos[bufferStackPos]) {
|
for (bufferPos[bufferStackPos] += 2; bufferPos[bufferStackPos]+1 < limit; ++bufferPos[bufferStackPos]) {
|
||||||
pos = bufferPos[bufferStackPos];
|
pos = bufferPos[bufferStackPos];
|
||||||
if (buffer[pos] == '*' && pos + 1 < limit
|
if (buffer[pos] == '*' && buffer[pos + 1] == '/') {
|
||||||
&& buffer[pos + 1] == '/') {
|
|
||||||
++bufferPos[bufferStackPos];
|
++bufferPos[bufferStackPos];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue