diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 0a0b960daf4..6090eab6a23 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,7 @@ +2003-07-02 Victor Mozgin + Added DOMTests::testBug39501(). + Improved filtering of expected failures/inconclusives in TortureTest. + 2003-06-30 John Camelon Added DOMTests::testAssignmentExpression() Added PreprocessorConditionalTest to ParserTestSuite. diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java index 9013738d198..488e85a6897 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java @@ -2195,4 +2195,8 @@ public class DOMTests extends BaseDOMTest { parse("unsigned char a[sizeof (struct sss)];"); } + public void testBug39501() throws Exception + { + parse("struct A { A() throw (int); };"); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/TortureTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/TortureTest.java index aaade12bfe6..c0a829aca61 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/TortureTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/TortureTest.java @@ -18,7 +18,6 @@ import java.io.StringReader; import java.io.StringWriter; import java.util.NoSuchElementException; import java.util.StringTokenizer; - import junit.framework.AssertionFailedError; import junit.framework.Test; @@ -89,7 +88,7 @@ public class TortureTest extends FractionalAutomatedTest { } } catch (FileNotFoundException e){ - testSources.put(resourcePath + "/default", "cpp"); + testSources.put(resourcePath, "cpp"); } if (!isEnabled) testSources.clear(); @@ -126,19 +125,84 @@ public class TortureTest extends FractionalAutomatedTest { fail(output); } + - - static protected boolean isExpectedToPass (String testCode) - { + static protected boolean isExpectedToPass (String testCode, File file) + { + String fileName = file.getName(); + + // Filter out gcc-specific tests that are not easy to detect automatically + if ( fileName.equals("init-2.c") + || fileName.equals("init-3.c") + || fileName.equals("struct-ini-4.c")) { + + // gcc-specific (and deprecated) designated initializers + // struct { int e1, e2; } v = { e2: 0 }; + + return false; + } + + if ( fileName.equals("stmtexpr3.C")) { + + // statements in expressions + // B() : a(({ 1; })) {} + + return false; + } + + if ( fileName.equals("widechar-1.c")) { + + // concatenation of incompatible literals + // char *s = L"a" "b"; + + return false; + } + + if ( fileName.equals("bf-common.h") + || fileName.equals("class-tests-1.h") + || fileName.equals("unclaimed-category-1.h")) { + + // ObjectiveC header file + + return false; + } + // Process some DejaGNU instructions - if (testCode.indexOf("{ dg-do run") >= 0) return true; - if (testCode.indexOf("{ dg-do link") >= 0) return true; if (testCode.indexOf("{ dg-error") >= 0) return false; if (testCode.indexOf("// ERROR") >= 0) return false; if (testCode.indexOf("- ERROR") >= 0) return false; if (testCode.indexOf("// XFAIL") >= 0) return false; + if (testCode.indexOf("- XFAIL") >= 0) return false; if (testCode.indexOf("{ xfail") >= 0) return false; if (testCode.indexOf("{ dg-preprocess") >= 0) return false; + if (testCode.indexOf("{ dg-do preprocess") >= 0) return false; + + // gcc extensions + if (testCode.indexOf("__attribute") >= 0) return false; + if (testCode.indexOf("__extension") >= 0) return false; + if (testCode.indexOf("__restrict") >= 0) return false; + if (testCode.indexOf("__const") >= 0) return false; + if (testCode.indexOf("__declspec") >= 0) return false; + if (testCode.indexOf("__alignof") >= 0) return false; + if (testCode.indexOf("__label") >= 0) return false; + if (testCode.indexOf("__real") >= 0) return false; + if (testCode.indexOf("__imag") >= 0) return false; + if (testCode.indexOf("extern template") >= 0) return false; + if (testCode.indexOf("inline template") >= 0) return false; + if (testCode.indexOf("static template") >= 0) return false; + if (testCode.indexOf("typeof") >= 0) return false; + if (testCode.indexOf(" asm") >= 0) return false; + if (testCode.indexOf(") return") >= 0) return false; + if (testCode.indexOf("#ident") >= 0) return false; + + // These are expected errors (not marked in the code) + if (testCode.indexOf("#include_next") >= 0) return false; + + // Long long literals are part of ANSI C99 + // if (containsLongLongLiterals(testCode)) return false; + + if (testCode.indexOf("{ dg-do run") >= 0) return true; + if (testCode.indexOf("{ dg-do link") >= 0) return true; return true; } @@ -164,7 +228,7 @@ public class TortureTest extends FractionalAutomatedTest { String testCode = code.toString(); - if (isExpectedToPass(testCode)) { + if (isExpectedToPass(testCode, file)) { ParseThread thread = new ParseThread(); thread.quickParse = quickParse; diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog index 99749fda463..7cd063bf86c 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog +++ b/core/org.eclipse.cdt.core/parser/ChangeLog @@ -1,3 +1,6 @@ +2003-07-02 Victor Mozgin + Fixed PR 39501 : Parser problems with throw clauses. + 2003-06-30 John Camelon Further restructuring of Parser for ISourceElementRequestor. Added interfaces/implementation for Simple Declarations. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index 8d410b49fce..d3a7f0c8c31 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -2260,11 +2260,22 @@ public class Parser implements IParser consume(); done = true; break; - case IToken.tIDENTIFIER : - duple = typeId(); - exceptionSpecIds.add( duple ); - try - { + case IToken.tCOMMA : + consume(); + break; + default : + String image = LA(1).getImage(); + try { + duple = typeId(); + exceptionSpecIds.add( duple ); + } catch (Backtrack e) { + failParse(); + Util.debugLog( "Unexpected Token =" + image ); + consume(); // eat this token anyway + continue; + } + + try { callback .declaratorThrowExceptionName( declarator); @@ -2273,13 +2284,6 @@ public class Parser implements IParser { } break; - case IToken.tCOMMA : - consume(); - break; - default : - Util.debugLog( "Unexpected Token =" + LA(1).getImage() ); - failParse(); - continue; } } if( exceptionSpecIds != null ) @@ -2303,24 +2307,28 @@ public class Parser implements IParser } } - if ( ( afterCVModifier != LA(1) || LT(1) == IToken.tSEMI ) && cvModifier != null ) + if ( afterCVModifier != LA(1) || LT(1) == IToken.tSEMI ) { // There were C++-specific clauses after const/volatile modifier // Then it is a marker for the method - try - { - callback.declaratorCVModifier( - declarator, - cvModifier); + if ( cvModifier != null ) { + try + { + callback.declaratorCVModifier( + declarator, + cvModifier); + } + catch (Exception e) + { + } + + if( cvModifier.getType() == IToken.t_const ) + d.setConst( true ); + if( cvModifier.getType() == IToken.t_volatile ) + d.setVolatile( true ); } - catch (Exception e) - { - } - - if( cvModifier.getType() == IToken.t_const ) - d.setConst( true ); - if( cvModifier.getType() == IToken.t_volatile ) - d.setVolatile( true ); + + afterCVModifier = mark(); // In this case (method) we can't expect K&R parameter declarations, // but we'll check anyway, for errorhandling @@ -2328,7 +2336,7 @@ public class Parser implements IParser else { // let's try this modifier as part of K&R parameter declaration - backup(beforeCVModifier); + if (cvModifier != null) backup(beforeCVModifier); } if (LT(1) != IToken.tSEMI)