mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Andrew Niefer
Core Fixed bug36771 - Outline view shows include with no name Fixed bug36714 - Parser fails on initial assignment using floating-suffix Revisted bug36816 - Incomplete #include stops outline view Tests Moved ACEFailedTest::testBug36771 to DOMTests Moved DOMFailedTest::testBug36714 to DOMTests Updated ScannerTestCase::testBug36816
This commit is contained in:
parent
ae473f009f
commit
2417cd02cb
7 changed files with 139 additions and 51 deletions
|
@ -1,3 +1,8 @@
|
|||
2003-04-25 Andrew Niefer
|
||||
Fixed bug36771 - Outline view shows include with no name
|
||||
Fixed bug36714 - Parser fails on initial assignment using floating-suffix
|
||||
Revisted bug36816 - Incomplete #include stops outline view
|
||||
|
||||
2003-04-25 John Camelon
|
||||
Fixed bug36852 - outline window doesn't show all functions
|
||||
Fixed bug36764 - Bit fields cause parse errors
|
||||
|
|
|
@ -711,8 +711,24 @@ public class Scanner implements IScanner {
|
|||
buff.append( (char)c );
|
||||
c = getChar();
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
if( floatingPoint ){
|
||||
//floating-suffix
|
||||
if( c == 'l' || c == 'L' || c == 'f' || c == 'F' ){
|
||||
c = getChar();
|
||||
}
|
||||
} else {
|
||||
//integer suffix
|
||||
if( c == 'u' || c == 'U' ){
|
||||
c = getChar();
|
||||
if( c == 'l' || c == 'L')
|
||||
c = getChar();
|
||||
} else if( c == 'l' || c == 'L' ){
|
||||
c = getChar();
|
||||
if( c == 'u' || c == 'U' )
|
||||
c = getChar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ungetChar( c );
|
||||
|
@ -1557,33 +1573,49 @@ public class Scanner implements IScanner {
|
|||
skipOverWhitespace();
|
||||
int c = getChar();
|
||||
int offset;
|
||||
|
||||
if( c == '/' ){
|
||||
c = getChar();
|
||||
if( c == '*' ){
|
||||
skipOverMultilineComment();
|
||||
skipOverWhitespace();
|
||||
c = getChar();
|
||||
} else {
|
||||
if( throwExceptionOnBadPreprocessorSyntax )
|
||||
throw new ScannerException( "Encountered ill-formed #include" );
|
||||
else return;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuffer fileName = new StringBuffer();
|
||||
boolean useIncludePath = true;
|
||||
if (c == '<') {
|
||||
c = getChar();
|
||||
while (c != '>') {
|
||||
if( c == NOCHAR ){
|
||||
//don't attempt an include if we hit the end of file before closing the brackets
|
||||
return;
|
||||
}
|
||||
fileName.append((char) c);
|
||||
c = getChar();
|
||||
}
|
||||
int endChar = -1;
|
||||
if( c == '<' ){
|
||||
endChar = '>';
|
||||
} else if ( c == '"' ){
|
||||
endChar = '"';
|
||||
useIncludePath = false;
|
||||
} else {
|
||||
if( throwExceptionOnBadPreprocessorSyntax )
|
||||
throw new ScannerException( "Encountered ill-formed #include");
|
||||
else return;
|
||||
}
|
||||
else if (c == '"') {
|
||||
c = getChar();
|
||||
while (c != '"') {
|
||||
if( c == NOCHAR ){
|
||||
//don't attempt an include if we hit the end of file before closing the quotes
|
||||
return;
|
||||
}
|
||||
fileName.append((char) c);
|
||||
|
||||
c = getChar();
|
||||
|
||||
while ((c != '\n') && (c != endChar) && (c != NOCHAR)){
|
||||
if( c == '\r' ){
|
||||
c = getChar();
|
||||
continue;
|
||||
}
|
||||
useIncludePath = false;
|
||||
// TO DO: Make sure the directory of the current file is in the
|
||||
// inclusion paths.
|
||||
fileName.append((char) c);
|
||||
c = getChar();
|
||||
}
|
||||
|
||||
if( c != endChar ){
|
||||
if( throwExceptionOnBadPreprocessorSyntax )
|
||||
throw new ScannerException( "Ill-formed #include: reached end of line before " + (char)endChar );
|
||||
else return;
|
||||
}
|
||||
|
||||
String f = fileName.toString();
|
||||
|
@ -1625,13 +1657,34 @@ public class Scanner implements IScanner {
|
|||
int c = getChar();
|
||||
if (c == '(') {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
c = getChar();
|
||||
c = getChar(true);
|
||||
while (c != ')') {
|
||||
if( c == NOCHAR ){
|
||||
return; //don't attempt #define if we don't hit the closing bracket
|
||||
if( c == '\\' ){
|
||||
c = getChar();
|
||||
if( c == '\r' )
|
||||
c = getChar();
|
||||
|
||||
if( c == '\n' ){
|
||||
c = getChar();
|
||||
continue;
|
||||
} else {
|
||||
ungetChar( c );
|
||||
if( throwExceptionOnBadPreprocessorSyntax )
|
||||
throw new ScannerException( "Unexpected '\\' in macro formal parameter list." );
|
||||
else return;
|
||||
}
|
||||
} else if( c == '\r' || c == '\n' ){
|
||||
if( throwExceptionOnBadPreprocessorSyntax )
|
||||
throw new ScannerException( "Unexpected newline in macro formal parameter list." );
|
||||
else return;
|
||||
} else if( c == NOCHAR ){
|
||||
if( throwExceptionOnBadPreprocessorSyntax )
|
||||
throw new ScannerException( "Unexpected EOF in macro formal parameter list." );
|
||||
else return;
|
||||
}
|
||||
|
||||
buffer.append((char) c);
|
||||
c = getChar();
|
||||
c = getChar(true);
|
||||
}
|
||||
|
||||
String parameters = buffer.toString();
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2003-04-25 Andrew Niefer
|
||||
Moved ACEFailedTest::testBug36771 to DOMTests
|
||||
Moved DOMFailedTest::testBug36714 to DOMTests
|
||||
Updated ScannerTestCase::testBug36816
|
||||
|
||||
2003-04-25 John Camelon
|
||||
Added DOMTests::testBug36852().
|
||||
Added DOMTests::testBug36764().
|
||||
|
|
|
@ -31,12 +31,6 @@ public class ACEFailedTest extends BaseDOMTest {
|
|||
super(arg);
|
||||
}
|
||||
|
||||
public void testBug36771() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
code.write("#include /**/ \"foo.h\"\n");
|
||||
failTest( code.toString());
|
||||
}
|
||||
|
||||
public void testBug36769() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
code.write("template <class A, B> cls<A, C>::operator op &() const {}\n");
|
||||
|
|
|
@ -50,15 +50,6 @@ public class DOMFailedTest extends BaseDOMTest {
|
|||
code.write("{};\n");
|
||||
failTest(code.toString());
|
||||
}
|
||||
|
||||
|
||||
public void testBug36714() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
code.write("unsigned long a = 0UL;\n");
|
||||
code.write("unsigned long a2 = 0L; \n");
|
||||
|
||||
failTest(code.toString());
|
||||
}
|
||||
|
||||
public void testBug36730(){
|
||||
failTest("FUNCTION_MACRO( 1, a );\n int i;");
|
||||
|
|
|
@ -1691,7 +1691,26 @@ public class DOMTests extends BaseDOMTest {
|
|||
TranslationUnit tu = parse( code.toString() );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testBug36771() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
code.write("#include /**/ \"foo.h\"\n");
|
||||
|
||||
TranslationUnit tu = parse( code.toString(), true, true );
|
||||
|
||||
List includes = tu.getInclusions();
|
||||
|
||||
assertEquals( includes.size(), 1 );
|
||||
Inclusion include = (Inclusion)includes.get(0);
|
||||
assertTrue( include.getName().equals("foo.h") );
|
||||
}
|
||||
|
||||
public void testBug36714() throws Exception {
|
||||
Writer code = new StringWriter();
|
||||
code.write("unsigned long a = 0UL;\n");
|
||||
code.write("unsigned long a2 = 0L; \n");
|
||||
|
||||
TranslationUnit tu = parse( code.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1264,16 +1264,37 @@ public class ScannerTestCase extends BaseScannerTest
|
|||
public void testBug36816() throws Exception
|
||||
{
|
||||
initializeScanner( "#include \"foo.h" );
|
||||
validateEOF();
|
||||
|
||||
try{
|
||||
validateEOF();
|
||||
} catch ( ScannerException e ){
|
||||
assertTrue( e.getMessage().equals( "Ill-formed #include: reached end of line before \"" ));
|
||||
}
|
||||
|
||||
initializeScanner( "#include <foo.h" );
|
||||
validateEOF();
|
||||
|
||||
try{
|
||||
validateEOF();
|
||||
} catch ( ScannerException e ){
|
||||
assertTrue( e.getMessage().equals( "Ill-formed #include: reached end of line before >" ));
|
||||
}
|
||||
initializeScanner( "#define FOO(A" );
|
||||
validateEOF();
|
||||
try{
|
||||
validateEOF();
|
||||
} catch( ScannerException e ){
|
||||
assertTrue( e.getMessage().equals( "Unexpected newline in macro formal parameter list."));
|
||||
}
|
||||
initializeScanner( "#define FOO(A \\ B" );
|
||||
try{
|
||||
validateEOF();
|
||||
} catch( ScannerException e ){
|
||||
assertTrue( e.getMessage().equals( "Unexpected '\\' in macro formal parameter list."));
|
||||
}
|
||||
|
||||
initializeScanner( "#define FOO(A) 1\n FOO(foo" );
|
||||
validateInteger("1");
|
||||
initializeScanner( "#define FOO(A,\\\nB) 1\n FOO(foo" );
|
||||
try{
|
||||
validateInteger("1");
|
||||
} catch( ScannerException e ){
|
||||
assertTrue( e.getMessage().equals( "Improper use of macro FOO" ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void testBug36255() throws Exception
|
||||
|
|
Loading…
Add table
Reference in a new issue