mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +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
|
2003-04-25 John Camelon
|
||||||
Fixed bug36852 - outline window doesn't show all functions
|
Fixed bug36852 - outline window doesn't show all functions
|
||||||
Fixed bug36764 - Bit fields cause parse errors
|
Fixed bug36764 - Bit fields cause parse errors
|
||||||
|
|
|
@ -711,8 +711,24 @@ public class Scanner implements IScanner {
|
||||||
buff.append( (char)c );
|
buff.append( (char)c );
|
||||||
c = getChar();
|
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 );
|
ungetChar( c );
|
||||||
|
@ -1557,33 +1573,49 @@ public class Scanner implements IScanner {
|
||||||
skipOverWhitespace();
|
skipOverWhitespace();
|
||||||
int c = getChar();
|
int c = getChar();
|
||||||
int offset;
|
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();
|
StringBuffer fileName = new StringBuffer();
|
||||||
boolean useIncludePath = true;
|
boolean useIncludePath = true;
|
||||||
if (c == '<') {
|
int endChar = -1;
|
||||||
c = getChar();
|
if( c == '<' ){
|
||||||
while (c != '>') {
|
endChar = '>';
|
||||||
if( c == NOCHAR ){
|
} else if ( c == '"' ){
|
||||||
//don't attempt an include if we hit the end of file before closing the brackets
|
endChar = '"';
|
||||||
return;
|
useIncludePath = false;
|
||||||
}
|
} else {
|
||||||
fileName.append((char) c);
|
if( throwExceptionOnBadPreprocessorSyntax )
|
||||||
c = getChar();
|
throw new ScannerException( "Encountered ill-formed #include");
|
||||||
}
|
else return;
|
||||||
}
|
}
|
||||||
else if (c == '"') {
|
|
||||||
c = getChar();
|
c = getChar();
|
||||||
while (c != '"') {
|
|
||||||
if( c == NOCHAR ){
|
while ((c != '\n') && (c != endChar) && (c != NOCHAR)){
|
||||||
//don't attempt an include if we hit the end of file before closing the quotes
|
if( c == '\r' ){
|
||||||
return;
|
|
||||||
}
|
|
||||||
fileName.append((char) c);
|
|
||||||
c = getChar();
|
c = getChar();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
useIncludePath = false;
|
fileName.append((char) c);
|
||||||
// TO DO: Make sure the directory of the current file is in the
|
c = getChar();
|
||||||
// inclusion paths.
|
}
|
||||||
|
|
||||||
|
if( c != endChar ){
|
||||||
|
if( throwExceptionOnBadPreprocessorSyntax )
|
||||||
|
throw new ScannerException( "Ill-formed #include: reached end of line before " + (char)endChar );
|
||||||
|
else return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String f = fileName.toString();
|
String f = fileName.toString();
|
||||||
|
@ -1625,13 +1657,34 @@ public class Scanner implements IScanner {
|
||||||
int c = getChar();
|
int c = getChar();
|
||||||
if (c == '(') {
|
if (c == '(') {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
c = getChar();
|
c = getChar(true);
|
||||||
while (c != ')') {
|
while (c != ')') {
|
||||||
if( c == NOCHAR ){
|
if( c == '\\' ){
|
||||||
return; //don't attempt #define if we don't hit the closing bracket
|
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);
|
buffer.append((char) c);
|
||||||
c = getChar();
|
c = getChar(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
String parameters = buffer.toString();
|
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
|
2003-04-25 John Camelon
|
||||||
Added DOMTests::testBug36852().
|
Added DOMTests::testBug36852().
|
||||||
Added DOMTests::testBug36764().
|
Added DOMTests::testBug36764().
|
||||||
|
|
|
@ -31,12 +31,6 @@ public class ACEFailedTest extends BaseDOMTest {
|
||||||
super(arg);
|
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 {
|
public void testBug36769() throws Exception {
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code.write("template <class A, B> cls<A, C>::operator op &() const {}\n");
|
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");
|
code.write("{};\n");
|
||||||
failTest(code.toString());
|
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(){
|
public void testBug36730(){
|
||||||
failTest("FUNCTION_MACRO( 1, a );\n int i;");
|
failTest("FUNCTION_MACRO( 1, a );\n int i;");
|
||||||
|
|
|
@ -1691,7 +1691,26 @@ public class DOMTests extends BaseDOMTest {
|
||||||
TranslationUnit tu = parse( code.toString() );
|
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
|
public void testBug36816() throws Exception
|
||||||
{
|
{
|
||||||
initializeScanner( "#include \"foo.h" );
|
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" );
|
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" );
|
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" );
|
initializeScanner( "#define FOO(A,\\\nB) 1\n FOO(foo" );
|
||||||
validateInteger("1");
|
try{
|
||||||
|
validateInteger("1");
|
||||||
|
} catch( ScannerException e ){
|
||||||
|
assertTrue( e.getMessage().equals( "Improper use of macro FOO" ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36255() throws Exception
|
public void testBug36255() throws Exception
|
||||||
|
|
Loading…
Add table
Reference in a new issue