mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CORE
Fixed bug36852 - outline window doesn't show all functions Fixed bug36764 - Bit fields cause parse errors Fixed bug36702 - Parser error when having function pointers as parameters TESTS Added DOMTests::testBug36852(). Added DOMTests::testBug36764(). Moved DOMFailedTests::testBug36702() to DOMTests(). JohnC
This commit is contained in:
parent
1afa3710ae
commit
c8a467dc65
11 changed files with 179 additions and 28 deletions
|
@ -0,0 +1,47 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2001 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corp. - Rational Software - initial implementation
|
||||||
|
******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class BitField implements IExpressionOwner {
|
||||||
|
|
||||||
|
|
||||||
|
public BitField( Declarator owner )
|
||||||
|
{
|
||||||
|
ownerDeclarator= owner;
|
||||||
|
}
|
||||||
|
private final Declarator ownerDeclarator;
|
||||||
|
private Expression expression = null;
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#getExpression()
|
||||||
|
*/
|
||||||
|
public Expression getExpression() {
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.IExpressionOwner#setExpression(org.eclipse.cdt.internal.core.dom.Expression)
|
||||||
|
*/
|
||||||
|
public void setExpression(Expression exp) {
|
||||||
|
expression = exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Declarator getOwnerDeclarator() {
|
||||||
|
return ownerDeclarator;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -918,5 +918,20 @@ public class DOMBuilder implements IParserCallback
|
||||||
public void expressionName(Object expression) {
|
public void expressionName(Object expression) {
|
||||||
Expression e = (Expression)expression;
|
Expression e = (Expression)expression;
|
||||||
e.add( currName ); }
|
e.add( currName ); }
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#startBitfield(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object startBitfield(Object declarator) {
|
||||||
|
return new BitField((Declarator)declarator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#endBitfield(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void endBitfield(Object bitfield) {
|
||||||
|
BitField b = (BitField)bitfield;
|
||||||
|
b.getOwnerDeclarator().setBitField( b );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -207,5 +207,21 @@ public class Declarator implements IExpressionOwner, IDeclaratorOwner {
|
||||||
public IDeclaratorOwner getOwnerDeclarator() {
|
public IDeclaratorOwner getOwnerDeclarator() {
|
||||||
return ownerDeclarator;
|
return ownerDeclarator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BitField bitField = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public BitField getBitField() {
|
||||||
|
return bitField;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param field
|
||||||
|
*/
|
||||||
|
public void setBitField(BitField field) {
|
||||||
|
bitField = field;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-04-25 John Camelon
|
||||||
|
Fixed bug36852 - outline window doesn't show all functions
|
||||||
|
Fixed bug36764 - Bit fields cause parse errors
|
||||||
|
Fixed bug36702 - Parser error when having function pointers as parameters
|
||||||
|
|
||||||
2003-04-24 John Camelon
|
2003-04-24 John Camelon
|
||||||
Fixed Bug36799 STL Testing: Parser fails on Variable Definition
|
Fixed Bug36799 STL Testing: Parser fails on Variable Definition
|
||||||
|
|
||||||
|
|
|
@ -716,5 +716,19 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
currName.setEnd(lastToken);
|
currName.setEnd(lastToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
Name currName = null;
|
Name currName = null;
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#startBitfield(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object startBitfield(Object declarator) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#endBitfield(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void endBitfield(Object bitfield) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,5 +138,8 @@ public interface IParserCallback {
|
||||||
public void templateTypeParameterAbort( Object typeParm );
|
public void templateTypeParameterAbort( Object typeParm );
|
||||||
public void templateTypeParameterInitialTypeId( Object typeParm );
|
public void templateTypeParameterInitialTypeId( Object typeParm );
|
||||||
public void templateTypeParameterEnd( Object typeParm );
|
public void templateTypeParameterEnd( Object typeParm );
|
||||||
|
|
||||||
|
public Object startBitfield(Object declarator);
|
||||||
|
public void endBitfield(Object bitfield);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -622,4 +622,17 @@ public class NullParserCallback implements IParserCallback {
|
||||||
public void expressionName(Object expression) {
|
public void expressionName(Object expression) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#startBitfield(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object startBitfield(Object declarator) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#endBitfield(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void endBitfield(Object bitfield) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -891,13 +891,15 @@ c, quick);
|
||||||
catch( Backtrack bt )
|
catch( Backtrack bt )
|
||||||
{
|
{
|
||||||
elaboratedTypeSpecifier(decl);
|
elaboratedTypeSpecifier(decl);
|
||||||
return;
|
flags.setEncounteredTypename(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
elaboratedTypeSpecifier(decl);
|
elaboratedTypeSpecifier(decl);
|
||||||
return;
|
flags.setEncounteredTypename(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case Token.t_enum:
|
case Token.t_enum:
|
||||||
if( !parm )
|
if( !parm )
|
||||||
|
@ -905,19 +907,21 @@ c, quick);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
enumSpecifier(decl);
|
enumSpecifier(decl);
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
catch( Backtrack bt )
|
catch( Backtrack bt )
|
||||||
{
|
{
|
||||||
// this is an elaborated class specifier
|
// this is an elaborated class specifier
|
||||||
elaboratedTypeSpecifier(decl);
|
elaboratedTypeSpecifier(decl);
|
||||||
return;
|
flags.setEncounteredTypename(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
elaboratedTypeSpecifier(decl);
|
elaboratedTypeSpecifier(decl);
|
||||||
return;
|
flags.setEncounteredTypename(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
|
@ -1428,6 +1432,16 @@ c, quick);
|
||||||
try{ callback.arrayDeclaratorEnd( array );} catch( Exception e ) {}
|
try{ callback.arrayDeclaratorEnd( array );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
case Token.tCOLON:
|
||||||
|
consume( Token.tCOLON );
|
||||||
|
Object bitfield = null;
|
||||||
|
try{ bitfield = callback.startBitfield( declarator );} catch( Exception e ) {}
|
||||||
|
Object expression = null;
|
||||||
|
try{ expression = callback.expressionBegin( bitfield );} catch( Exception e ) {}
|
||||||
|
constantExpression(expression);
|
||||||
|
try{ callback.expressionEnd( expression ); } catch( Exception e ) {}
|
||||||
|
try{ callback.endBitfield( bitfield );} catch( Exception e ) {}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2337,7 +2351,9 @@ c, quick);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
// TO DO: we need more literals...
|
// TO DO: we need more literals...
|
||||||
case Token.tINTEGER:
|
case Token.tINTEGER:
|
||||||
|
case Token.tFLOATINGPT:
|
||||||
case Token.tSTRING:
|
case Token.tSTRING:
|
||||||
|
case Token.tLSTRING:
|
||||||
case Token.t_false:
|
case Token.t_false:
|
||||||
case Token.t_true:
|
case Token.t_true:
|
||||||
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-04-25 John Camelon
|
||||||
|
Added DOMTests::testBug36852().
|
||||||
|
Added DOMTests::testBug36764().
|
||||||
|
Moved DOMFailedTests::testBug36702() to DOMTests().
|
||||||
|
|
||||||
2003-04-24 John Camelon
|
2003-04-24 John Camelon
|
||||||
Moved fixed tests from FailedTests to DOMTests.
|
Moved fixed tests from FailedTests to DOMTests.
|
||||||
Added DOMTests::testBug36799().
|
Added DOMTests::testBug36799().
|
||||||
|
|
|
@ -64,26 +64,4 @@ public class DOMFailedTest extends BaseDOMTest {
|
||||||
failTest("FUNCTION_MACRO( 1, a );\n int i;");
|
failTest("FUNCTION_MACRO( 1, a );\n int i;");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36702() throws Exception
|
|
||||||
{
|
|
||||||
Writer code = new StringWriter();
|
|
||||||
code.write( "void mad_decoder_init(struct mad_decoder *, void *,\n" );
|
|
||||||
code.write( " enum mad_flow (*)(void *, struct mad_stream *),\n" );
|
|
||||||
code.write( " enum mad_flow (*)(void *, struct mad_header const *),\n" );
|
|
||||||
code.write( " enum mad_flow (*)(void *,\n" );
|
|
||||||
code.write( " struct mad_stream const *,\n" );
|
|
||||||
code.write( " struct mad_frame *),\n" );
|
|
||||||
code.write( " enum mad_flow (*)(void *,\n" );
|
|
||||||
code.write( " struct mad_header const *,\n" );
|
|
||||||
code.write( " struct mad_pcm *),\n" );
|
|
||||||
code.write( " enum mad_flow (*)(void *,\n" );
|
|
||||||
code.write( " struct mad_stream *,\n" );
|
|
||||||
code.write( " struct mad_frame *),\n" );
|
|
||||||
code.write( " enum mad_flow (*)(void *, void *, unsigned int *)\n" );
|
|
||||||
code.write( ");\n" );
|
|
||||||
|
|
||||||
failTest( code.toString() );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1654,5 +1654,44 @@ public class DOMTests extends BaseDOMTest {
|
||||||
assertEquals( tu.getDeclarations().size(), 1 );
|
assertEquals( tu.getDeclarations().size(), 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug36852() throws Exception
|
||||||
|
{
|
||||||
|
Writer code = new StringWriter();
|
||||||
|
code.write( "int CBT::senseToAllRect( double id_standardQuot = DOSE, double id_minToleranz =15.0,\n" );
|
||||||
|
code.write( "double id_maxToleranz = 15.0, unsigned int iui_minY = 0, \n" );
|
||||||
|
code.write( "unsigned int iui_maxY = HEIGHT );\n" );
|
||||||
|
TranslationUnit tu = parse( code.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug36764() throws Exception
|
||||||
|
{
|
||||||
|
TranslationUnit tu = parse( "struct{ int x : 4; int y : 8; };" );
|
||||||
|
assertEquals( tu.getDeclarations().size(), 1 );
|
||||||
|
assertEquals( ((ClassSpecifier)((SimpleDeclaration)tu.getDeclarations().get(0)).getTypeSpecifier()).getDeclarations().size(), 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug36702() throws Exception
|
||||||
|
{
|
||||||
|
Writer code = new StringWriter();
|
||||||
|
code.write( "void mad_decoder_init(struct mad_decoder *, void *,\n" );
|
||||||
|
code.write( " enum mad_flow (*)(void *, struct mad_stream *),\n" );
|
||||||
|
code.write( " enum mad_flow (*)(void *, struct mad_header const *),\n" );
|
||||||
|
code.write( " enum mad_flow (*)(void *,\n" );
|
||||||
|
code.write( " struct mad_stream const *,\n" );
|
||||||
|
code.write( " struct mad_frame *),\n" );
|
||||||
|
code.write( " enum mad_flow (*)(void *,\n" );
|
||||||
|
code.write( " struct mad_header const *,\n" );
|
||||||
|
code.write( " struct mad_pcm *),\n" );
|
||||||
|
code.write( " enum mad_flow (*)(void *,\n" );
|
||||||
|
code.write( " struct mad_stream *,\n" );
|
||||||
|
code.write( " struct mad_frame *),\n" );
|
||||||
|
code.write( " enum mad_flow (*)(void *, void *, unsigned int *)\n" );
|
||||||
|
code.write( ");\n" );
|
||||||
|
|
||||||
|
TranslationUnit tu = parse( code.toString() );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue