1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-02 13:13:36 +02:00

ASSIGNED - bug 173110: C99 parser contribution

https://bugs.eclipse.org/bugs/show_bug.cgi?id=173110

Initial contribution by Mike Kucera
This commit is contained in:
Chris Recoskie 2007-02-08 21:06:02 +00:00
parent b84f87ee1a
commit 87cc279731
28 changed files with 209 additions and 11 deletions

View file

@ -94,7 +94,14 @@ public class FileBasePluginTest extends TestCase {
static Class className; static Class className;
static ICProject cPrj; static ICProject cPrj;
private void initialize(Class aClassName){ public FileBasePluginTest() {
}
public FileBasePluginTest(String name) {
super(name);
}
private void initialize(Class aClassName){
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){ if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset(); //(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();

View file

@ -77,6 +77,14 @@ public class AST2BaseTest extends BaseTestCase {
private static final IParserLogService NULL_LOG = new NullLogService(); private static final IParserLogService NULL_LOG = new NullLogService();
public AST2BaseTest() {
super();
}
public AST2BaseTest(String name) {
super(name);
}
protected IASTTranslationUnit parse( String code, ParserLanguage lang ) throws ParserException { protected IASTTranslationUnit parse( String code, ParserLanguage lang ) throws ParserException {
return parse(code, lang, false, true ); return parse(code, lang, false, true );
} }

View file

@ -21,6 +21,15 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
*/ */
public class AST2CPPSpecFailingTest extends AST2SpecBaseTest { public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
public AST2CPPSpecFailingTest() {
}
public AST2CPPSpecFailingTest(String name) {
super(name);
}
/** /**
[--Start Example(CPP 2.3-2): [--Start Example(CPP 2.3-2):
??=define arraycheck(a,b) a??(b??) ??!??! b??(a??) ??=define arraycheck(a,b) a??(b??) ??!??! b??(a??)

View file

@ -18,6 +18,13 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
*/ */
public class AST2CPPSpecTest extends AST2SpecBaseTest { public class AST2CPPSpecTest extends AST2SpecBaseTest {
public AST2CPPSpecTest() {
}
public AST2CPPSpecTest(String name) {
super(name);
}
/** /**
* Note: Each example should have the example in a comment before * Note: Each example should have the example in a comment before
* the tested method with the following format: * the tested method with the following format:
@ -38,6 +45,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
* *
*/ */
/** /**
[--Start Example(CPP 2.4-5): [--Start Example(CPP 2.4-5):
int x=x+++++y; int x=x+++++y;

View file

@ -107,7 +107,14 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
public class AST2CPPTests extends AST2BaseTest { public class AST2CPPTests extends AST2BaseTest {
public void testBug102825() throws Exception { public AST2CPPTests() {
}
public AST2CPPTests(String name) {
super(name);
}
public void testBug102825() throws Exception {
StringBuffer buffer = new StringBuffer("#define CURLOPTTYPE_OBJECTPOINT 10000\n" ); //$NON-NLS-1$ StringBuffer buffer = new StringBuffer("#define CURLOPTTYPE_OBJECTPOINT 10000\n" ); //$NON-NLS-1$
buffer.append("#define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number\n" ); //$NON-NLS-1$ buffer.append("#define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number\n" ); //$NON-NLS-1$
buffer.append("typedef enum {\n" ); //$NON-NLS-1$ buffer.append("typedef enum {\n" ); //$NON-NLS-1$

View file

@ -17,6 +17,13 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
*/ */
public class AST2CSpecFailingTest extends AST2SpecBaseTest { public class AST2CSpecFailingTest extends AST2SpecBaseTest {
public AST2CSpecFailingTest() {
}
public AST2CSpecFailingTest(String name) {
super(name);
}
/** /**
[--Start Example(C 6.7.7-6): [--Start Example(C 6.7.7-6):
typedef signed int t; typedef signed int t;

View file

@ -17,6 +17,13 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
*/ */
public class AST2CSpecTest extends AST2SpecBaseTest { public class AST2CSpecTest extends AST2SpecBaseTest {
public AST2CSpecTest() {
}
public AST2CSpecTest(String name) {
super(name);
}
/** /**
[--Start Example(C 4-6): [--Start Example(C 4-6):
#ifdef _ _STDC_IEC_559_ _ // FE_UPWARD defined #ifdef _ _STDC_IEC_559_ _ // FE_UPWARD defined

View file

@ -48,7 +48,14 @@ public class AST2FileBasePluginTest extends TestCase {
static Class className; static Class className;
static ICProject cPrj; static ICProject cPrj;
private void initialize(Class aClassName){ public AST2FileBasePluginTest() {
}
public AST2FileBasePluginTest(String name) {
super(name);
}
private void initialize(Class aClassName){
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){ if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset(); //(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();

View file

@ -55,7 +55,15 @@ import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
* @author dsteffle * @author dsteffle
*/ */
public class AST2KnRTests extends AST2BaseTest { public class AST2KnRTests extends AST2BaseTest {
public void testSimpleKRCTest1() throws Exception {
public AST2KnRTests() {
}
public AST2KnRTests(String name) {
super(name);
}
public void testSimpleKRCTest1() throws Exception {
StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$ StringBuffer buffer = new StringBuffer(); //$NON-NLS-1$
buffer.append( "int f(char x);\n" ); //$NON-NLS-1$ buffer.append( "int f(char x);\n" ); //$NON-NLS-1$
buffer.append( "int f(x) char x;\n" ); //$NON-NLS-1$ buffer.append( "int f(x) char x;\n" ); //$NON-NLS-1$

View file

@ -46,7 +46,14 @@ import org.eclipse.core.resources.IFile;
*/ */
public class AST2SelectionParseBaseTest extends FileBasePluginTest { public class AST2SelectionParseBaseTest extends FileBasePluginTest {
private static final IParserLogService NULL_LOG = new NullLogService(); public AST2SelectionParseBaseTest() {
}
public AST2SelectionParseBaseTest(String name) {
super(name);
}
private static final IParserLogService NULL_LOG = new NullLogService();
public AST2SelectionParseBaseTest(String name, Class className) { public AST2SelectionParseBaseTest(String name, Class className) {
super(name, className); super(name, className);

View file

@ -48,6 +48,13 @@ import org.eclipse.core.resources.IFile;
*/ */
public class AST2SelectionParseTest extends AST2SelectionParseBaseTest { public class AST2SelectionParseTest extends AST2SelectionParseBaseTest {
public AST2SelectionParseTest() {
}
public AST2SelectionParseTest(String name, Class className) {
super(name, className);
}
public AST2SelectionParseTest(String name) { public AST2SelectionParseTest(String name) {
super(name, AST2SelectionParseTest.class); super(name, AST2SelectionParseTest.class);
} }

View file

@ -52,6 +52,14 @@ import junit.framework.TestCase;
public class AST2SpecBaseTest extends TestCase { public class AST2SpecBaseTest extends TestCase {
private static final IParserLogService NULL_LOG = new NullLogService(); private static final IParserLogService NULL_LOG = new NullLogService();
public AST2SpecBaseTest() {
super();
}
public AST2SpecBaseTest(String name) {
super(name);
}
/** /**
* checkSemantics is used to specify whether the example should have semantics checked * checkSemantics is used to specify whether the example should have semantics checked
* since several spec examples have syntactically correct code ONLY this flag was added * since several spec examples have syntactically correct code ONLY this flag was added

View file

@ -61,6 +61,13 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
*/ */
public class AST2TemplateTests extends AST2BaseTest { public class AST2TemplateTests extends AST2BaseTest {
public AST2TemplateTests() {
}
public AST2TemplateTests(String name) {
super(name);
}
public void testBasicClassTemplate() throws Exception { public void testBasicClassTemplate() throws Exception {
IASTTranslationUnit tu = parse( "template <class T> class A{ T t; };", ParserLanguage.CPP ); //$NON-NLS-1$ IASTTranslationUnit tu = parse( "template <class T> class A{ T t; };", ParserLanguage.CPP ); //$NON-NLS-1$
CPPNameCollector col = new CPPNameCollector(); CPPNameCollector col = new CPPNameCollector();

View file

@ -101,6 +101,15 @@ public class AST2Tests extends AST2BaseTest {
return suite(AST2Tests.class); return suite(AST2Tests.class);
} }
public AST2Tests() {
super();
}
public AST2Tests(String name) {
super(name);
}
public void testBug75189() throws Exception { public void testBug75189() throws Exception {
parseAndCheckBindings( "struct A{};typedef int (*F) (A*);" ); //$NON-NLS-1$ parseAndCheckBindings( "struct A{};typedef int (*F) (A*);" ); //$NON-NLS-1$
} }

View file

@ -18,6 +18,11 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
public class AST2UtilOldTests extends AST2BaseTest { public class AST2UtilOldTests extends AST2BaseTest {
public AST2UtilOldTests() {
}
public AST2UtilOldTests(String name) {
super(name);
}
// Kind PRIMARY_EMPTY : void // Kind PRIMARY_EMPTY : void
public void testPrimaryEmpty() throws Exception public void testPrimaryEmpty() throws Exception
{ {

View file

@ -27,6 +27,13 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
* @author dsteffle * @author dsteffle
*/ */
public class AST2UtilTests extends AST2BaseTest { public class AST2UtilTests extends AST2BaseTest {
public AST2UtilTests() {
}
public AST2UtilTests(String name) {
super(name);
}
public void testSimpleSignature() throws Exception { public void testSimpleSignature() throws Exception {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
buff.append("int l, m, n=0;\n"); //$NON-NLS-1$ buff.append("int l, m, n=0;\n"); //$NON-NLS-1$

View file

@ -21,6 +21,13 @@ import org.eclipse.core.resources.IFile;
*/ */
public class CDOMBaseTest extends FileBasePluginTest { public class CDOMBaseTest extends FileBasePluginTest {
public CDOMBaseTest() {
}
public CDOMBaseTest(String name) {
super(name);
}
public CDOMBaseTest(String name, Class className) { public CDOMBaseTest(String name, Class className) {
super(name, className); super(name, className);
} }

View file

@ -28,6 +28,13 @@ import org.eclipse.core.runtime.jobs.Job;
*/ */
public class CodeReaderCacheTest extends CDOMBaseTest { public class CodeReaderCacheTest extends CDOMBaseTest {
public CodeReaderCacheTest() {
}
public CodeReaderCacheTest(String name, Class className) {
super(name, className);
}
public CodeReaderCacheTest(String name) { public CodeReaderCacheTest(String name) {
super(name, CodeReaderCacheTest.class); super(name, CodeReaderCacheTest.class);
} }

View file

@ -94,7 +94,13 @@ public class CompleteParser2Tests extends TestCase {
private static final NullLogService NULL_LOG = new NullLogService(); private static final NullLogService NULL_LOG = new NullLogService();
static private class CPPNameCollector extends CPPASTVisitor { public CompleteParser2Tests() {
}
public CompleteParser2Tests(String name) {
super(name);
}
static private class CPPNameCollector extends CPPASTVisitor {
{ {
shouldVisitNames = true; shouldVisitNames = true;
} }

View file

@ -45,7 +45,14 @@ public class DOMFileBasePluginTest extends TestCase {
static Class className; static Class className;
static ICProject cPrj; static ICProject cPrj;
private void initialize(Class aClassName) { public DOMFileBasePluginTest() {
}
public DOMFileBasePluginTest(String name) {
super(name);
}
private void initialize(Class aClassName) {
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){ if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset(); //(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();

View file

@ -21,6 +21,13 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
*/ */
public class DOMGCCSelectionParseExtensionsTest extends DOMSelectionParseBaseTest { public class DOMGCCSelectionParseExtensionsTest extends DOMSelectionParseBaseTest {
public DOMGCCSelectionParseExtensionsTest() {
}
public DOMGCCSelectionParseExtensionsTest(String name, Class className) {
super(name, className);
}
public DOMGCCSelectionParseExtensionsTest(String name) { public DOMGCCSelectionParseExtensionsTest(String name) {
super(name, DOMGCCSelectionParseExtensionsTest.class); super(name, DOMGCCSelectionParseExtensionsTest.class);
} }

View file

@ -45,7 +45,14 @@ import org.eclipse.core.runtime.content.IContentType;
*/ */
public class DOMLocationInclusionTests extends AST2FileBasePluginTest { public class DOMLocationInclusionTests extends AST2FileBasePluginTest {
public void testBug97967() throws Exception { public DOMLocationInclusionTests() {
}
public DOMLocationInclusionTests(String name, Class className) {
super(name, className);
}
public void testBug97967() throws Exception {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("#ifndef _INCLUDE_H_\n"); //$NON-NLS-1$ buffer.append("#ifndef _INCLUDE_H_\n"); //$NON-NLS-1$
buffer.append("#define _INCLUDE_H_\n"); //$NON-NLS-1$ buffer.append("#define _INCLUDE_H_\n"); //$NON-NLS-1$

View file

@ -31,7 +31,14 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
public class DOMLocationMacroTests extends AST2BaseTest { public class DOMLocationMacroTests extends AST2BaseTest {
public void testObjectStyleMacroExpansionSimpleDeclarator() throws Exception public DOMLocationMacroTests() {
}
public DOMLocationMacroTests(String name) {
super(name);
}
public void testObjectStyleMacroExpansionSimpleDeclarator() throws Exception
{ {
StringBuffer buffer = new StringBuffer( "#define ABC D\n" ); //$NON-NLS-1$ StringBuffer buffer = new StringBuffer( "#define ABC D\n" ); //$NON-NLS-1$
buffer.append( "int ABC;"); //$NON-NLS-1$ buffer.append( "int ABC;"); //$NON-NLS-1$

View file

@ -63,7 +63,10 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
*/ */
public class DOMLocationTests extends AST2BaseTest { public class DOMLocationTests extends AST2BaseTest {
private static final String _TEXT_ = "<text>"; //$NON-NLS-1$ public DOMLocationTests() {
}
private static final String _TEXT_ = "<text>"; //$NON-NLS-1$
public DOMLocationTests(String name) { public DOMLocationTests(String name) {
setName(name); setName(name);

View file

@ -25,6 +25,13 @@ import org.eclipse.core.resources.IFile;
*/ */
public class DOMSelectionParseBaseTest extends DOMFileBasePluginTest { public class DOMSelectionParseBaseTest extends DOMFileBasePluginTest {
public DOMSelectionParseBaseTest() {
}
public DOMSelectionParseBaseTest(String name) {
super(name);
}
public DOMSelectionParseBaseTest(String name, Class className) { public DOMSelectionParseBaseTest(String name, Class className) {
super(name, className); super(name, className);
} }

View file

@ -43,6 +43,13 @@ import org.eclipse.core.resources.IFile;
*/ */
public class DOMSelectionParseTest extends DOMSelectionParseBaseTest { public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
public DOMSelectionParseTest() {
}
public DOMSelectionParseTest(String name, Class className) {
super(name, className);
}
public DOMSelectionParseTest(String name) { public DOMSelectionParseTest(String name) {
super(name, DOMSelectionParseTest.class); super(name, DOMSelectionParseTest.class);
} }

View file

@ -35,6 +35,13 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
*/ */
public class GCCCompleteParseExtensionsTest extends AST2BaseTest { public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
public GCCCompleteParseExtensionsTest() {
}
public GCCCompleteParseExtensionsTest(String name) {
super(name);
}
private IASTTranslationUnit parseGCC(String code) throws ParserException { private IASTTranslationUnit parseGCC(String code) throws ParserException {
IASTTranslationUnit tu = parse(code, ParserLanguage.C, true, true); IASTTranslationUnit tu = parse(code, ParserLanguage.C, true, true);

View file

@ -31,7 +31,14 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
*/ */
public class GCCTests extends AST2BaseTest { public class GCCTests extends AST2BaseTest {
public void testGCC20000113() throws Exception { public GCCTests() {
}
public GCCTests(String name) {
super(name);
}
public void testGCC20000113() throws Exception {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append( "struct x { \n" ); //$NON-NLS-1$ buffer.append( "struct x { \n" ); //$NON-NLS-1$
buffer.append( " unsigned x1:1; \n" ); //$NON-NLS-1$ buffer.append( " unsigned x1:1; \n" ); //$NON-NLS-1$