[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Solution to bug#43373, bug#43371, and bug#43143
|
Core:
Solution
to bug#43373: No reference to static member in definition
(Major)
Solution
to bug#43371: constructor incorrectly marked private
(Normal)
Tests:
Added
CompleteParseASTTest.testBug43373()
Added
QuickParseASTTests.testBug43371()
UI:
Solution
to bug#43143: Naming of Code Assist Menus/Tab are not consistent
changed
both names to Content Assist. No tests provided.
Hoda Amer
Staff Software Engineer
Rational Software - IBM Software Group
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.184
diff -u -r1.184 ChangeLog
--- ChangeLog 23 Sep 2003 15:17:20 -0000 1.184
+++ ChangeLog 23 Sep 2003 19:53:32 -0000
@@ -1,3 +1,7 @@
+2003-09-23 Hoda Amer
+ Solution to bug#43143: Naming of Code Assist Menus/Tab are not consistent
+ changed both names to Content Assist. No tests provided.
+
2003-09-22 Bogdan Gheorghe
Got rid of the C/C++ Project property page (only the indexer tab
was left). Here are the changes:
Index: src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java,v
retrieving revision 1.11
diff -u -r1.11 CEditorPreferencePage.java
--- src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java 23 Sep 2003 13:54:28 -0000 1.11
+++ src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java 23 Sep 2003 19:53:33 -0000
@@ -950,7 +950,7 @@
item.setControl(createColorPage(folder));
item = new TabItem(folder, SWT.NONE);
- item.setText("Code A&ssist");
+ item.setText("Content A&ssist");
item.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT));
item.setControl(createContentAssistPage(folder));
Index: model/org/eclipse/cdt/internal/core/model/CModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder.java,v
retrieving revision 1.18
diff -u -r1.18 CModelBuilder.java
--- model/org/eclipse/cdt/internal/core/model/CModelBuilder.java 23 Sep 2003 13:54:21 -0000 1.18
+++ model/org/eclipse/cdt/internal/core/model/CModelBuilder.java 23 Sep 2003 19:52:48 -0000
@@ -521,6 +521,10 @@
}
}
+ methodElement.setParameterTypes(parameterTypes);
+ methodElement.setReturnType( ASTUtil.getType(functionDeclaration.getReturnType()) );
+ methodElement.setStatic(functionDeclaration.isStatic());
+
// Common settings for method declaration
methodElement.setVisibility(methodDeclaration.getVisiblity());
methodElement.setVolatile(methodDeclaration.isVolatile());
@@ -535,15 +539,16 @@
}
else // instance of IASTFunction
{
+ FunctionDeclaration functionElement = null;
if (functionDeclaration.hasFunctionBody())
{
// function
if(!isTemplate){
Function newElement = new Function( parent, name );
- element = newElement;
+ functionElement = newElement;
} else {
FunctionTemplate newElement = new FunctionTemplate( parent, name );
- element = newElement;
+ functionElement = newElement;
}
}
else
@@ -551,17 +556,17 @@
// functionDeclaration
if(!isTemplate){
FunctionDeclaration newElement = new FunctionDeclaration( parent, name );
- element = newElement;
+ functionElement = newElement;
} else {
FunctionTemplate newElement = new FunctionTemplate( parent, name );
- element = newElement;
+ functionElement = newElement;
}
}
+ functionElement.setParameterTypes(parameterTypes);
+ functionElement.setReturnType( ASTUtil.getType(functionDeclaration.getReturnType()) );
+ functionElement.setStatic(functionDeclaration.isStatic());
+ element = functionElement;
}
- element.setParameterTypes(parameterTypes);
- element.setReturnType( ASTUtil.getType(functionDeclaration.getReturnType()) );
- element.setStatic(functionDeclaration.isStatic());
-
// add to parent
parent.addChild( element );
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.133
diff -u -r1.133 ChangeLog
--- parser/ChangeLog 19 Sep 2003 16:00:53 -0000 1.133
+++ parser/ChangeLog 23 Sep 2003 19:52:49 -0000
@@ -1,3 +1,7 @@
+2003-09-23 Hoda Amer
+ Solution to bug#43373: No reference to static member in definition
+ Solution to bug#43371: constructor incorrectly marked private
+
2003-09-18 Andrew Niefer
- modified Symbol table interfaces to use Lists & Maps instead of LinkedList and HashMap
- fixed warnings in ParserSymbolTable
Index: parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java,v
retrieving revision 1.32
diff -u -r1.32 IASTFactory.java
--- parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 15 Sep 2003 22:50:25 -0000 1.32
+++ parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 23 Sep 2003 19:52:49 -0000
@@ -147,7 +147,7 @@
boolean isVolatile,
boolean isVirtual,
boolean isExplicit,
- boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isDefinition ) throws ASTSemanticException;
+ boolean isPureVirtual, List constructorChain, boolean isDefinition ) throws ASTSemanticException;
public IASTAbstractDeclaration createAbstractDeclaration(
boolean isConst,
boolean isVolatile,
Index: parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java,v
retrieving revision 1.19
diff -u -r1.19 DeclarationWrapper.java
--- parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java 15 Sep 2003 22:50:25 -0000 1.19
+++ parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java 23 Sep 2003 19:52:49 -0000
@@ -468,7 +468,6 @@
virtual,
explicit,
declarator.isPureVirtual(),
- ASTAccessVisibility.PUBLIC,
declarator.getConstructorMemberInitializers(), declarator.hasFunctionBody() );
}
/**
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTField.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTField.java,v
retrieving revision 1.4
diff -u -r1.4 ASTField.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTField.java 14 Aug 2003 15:33:27 -0000 1.4
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTField.java 23 Sep 2003 19:52:49 -0000
@@ -37,9 +37,9 @@
* @param references
* @param visibility
*/
- public ASTField(ISymbol newSymbol, IASTAbstractDeclaration abstractDeclaration, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, int startingOffset, int nameOffset, List references, IASTExpression constructorExpression, ASTAccessVisibility visibility)
+ public ASTField(ISymbol newSymbol, IASTAbstractDeclaration abstractDeclaration, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, int startingOffset, int nameOffset, List references, boolean previouslyDeclared, IASTExpression constructorExpression, ASTAccessVisibility visibility)
{
- super( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references, constructorExpression );
+ super( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references, constructorExpression, previouslyDeclared );
this.visibility = visibility;
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTVariable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTVariable.java,v
retrieving revision 1.4
diff -u -r1.4 ASTVariable.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTVariable.java 14 Aug 2003 15:33:27 -0000 1.4
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTVariable.java 23 Sep 2003 19:52:49 -0000
@@ -29,6 +29,7 @@
*/
public class ASTVariable extends ASTSymbol implements IASTVariable
{
+ private final boolean previouslyDeclared;
private final IASTExpression constructorExpression;
protected final ASTReferenceStore referenceDelegate;
private final ASTQualifiedNamedElement qualifiedName;
@@ -45,7 +46,7 @@
* @param nameOffset
* @param references
*/
- public ASTVariable(ISymbol newSymbol, IASTAbstractDeclaration abstractDeclaration, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, int startingOffset, int nameOffset, List references, IASTExpression constructorExpression )
+ public ASTVariable(ISymbol newSymbol, IASTAbstractDeclaration abstractDeclaration, IASTInitializerClause initializerClause, IASTExpression bitfieldExpression, int startingOffset, int nameOffset, List references, IASTExpression constructorExpression, boolean previouslyDeclared )
{
super( newSymbol );
this.abstractDeclaration = abstractDeclaration;
@@ -56,6 +57,7 @@
setNameOffset( nameOffset );
referenceDelegate = new ASTReferenceStore( references );
qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), newSymbol.getName() );
+ this.previouslyDeclared =previouslyDeclared;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTVariable#isAuto()
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java,v
retrieving revision 1.43
diff -u -r1.43 CompleteParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 19 Sep 2003 16:00:53 -0000 1.43
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 23 Sep 2003 19:52:50 -0000
@@ -157,6 +157,10 @@
return result;
}
+ protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, String name, List references, boolean throwOnError ) throws ASTSemanticException{
+ return lookupQualifiedName(startingScope, name, TypeInfo.t_any, null, 0, references, throwOnError);
+ }
+
protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, String name, TypeInfo.eType type, List parameters, int offset, List references, boolean throwOnError ) throws ASTSemanticException
{
ISymbol result = null;
@@ -1406,7 +1410,8 @@
boolean isVirtual,
boolean isExplicit,
boolean isPureVirtual,
- ASTAccessVisibility visibility, List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
+ List constructorChain,
+ boolean isFunctionDefinition ) throws ASTSemanticException
{
List references = new ArrayList();
IContainerSymbol ownerScope = scopeToSymbol( scope );
@@ -1437,7 +1442,12 @@
if(parentSymbol == null){
parentSymbol = (IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_namespace, null, offset, references, false);
}
- if(parentSymbol == null)
+ if(parentSymbol == null){
+ parentSymbol = (IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_struct, null, offset, references, false);
+ }
+ if(parentSymbol == null){
+ parentSymbol = (IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_union, null, offset, references, false);
+ } if(parentSymbol == null)
break;
else {
parentScope = parentSymbol;
@@ -1445,12 +1455,16 @@
}
}
- if((parentScope != null) && (parentScope.getType() == TypeInfo.t_class)){
- IASTClassSpecifier methodParentScope = (IASTClassSpecifier)parentScope.getASTExtension().getPrimaryDeclaration();
+ if((parentScope != null) &&
+ ( (parentScope.getType() == TypeInfo.t_class)
+ || (parentScope.getType() == TypeInfo.t_struct)
+ || (parentScope.getType() == TypeInfo.t_union))
+ ){
+ IASTScope methodParentScope = (IASTScope)parentScope.getASTExtension().getPrimaryDeclaration();
return createMethod(methodParentScope, functionName,nameEndOffset, parameters, returnType,
exception, isInline, isFriend, isStatic, startOffset, offset,
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
- visibility, constructorChain, references, isFunctionDefinition);
+ ASTAccessVisibility.PRIVATE, constructorChain, references, isFunctionDefinition);
}
}
@@ -1852,6 +1866,59 @@
int nameOffset, IASTExpression constructorExpression) throws ASTSemanticException
{
List references = new ArrayList();
+ IContainerSymbol ownerScope = scopeToSymbol( scope );
+
+ // check if this is a scoped field, not a variable
+ StringTokenizer tokenizer = new StringTokenizer(name,DOUBLE_COLON);
+ int tokencount = tokenizer.countTokens();
+ if(tokencount > 1){
+ List tokens = new ArrayList();
+ String oneToken = "";
+ // This is NOT a function. This is a method definition
+ while (tokenizer.hasMoreTokens()){
+ oneToken = tokenizer.nextToken();
+ tokens.add(oneToken);
+ }
+
+ String fieldName = oneToken;
+ String parentName = name.substring(0, name.lastIndexOf(DOUBLE_COLON));
+
+ int numOfTokens = 1;
+ int offset = nameOffset;
+ IContainerSymbol parentScope = ownerScope;
+ Iterator i = tokens.iterator();
+ while (i.hasNext() && (numOfTokens++) < tokens.size()){
+ String token = (String) i.next();
+ IContainerSymbol parentSymbol =
+ (IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_class, null, offset, references, false);
+ if(parentSymbol == null){
+ parentSymbol = (IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_namespace, null, offset, references, false);
+ }
+ if(parentSymbol == null){
+ parentSymbol = (IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_struct, null, offset, references, false);
+ }
+ if(parentSymbol == null){
+ parentSymbol = (IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_union, null, offset, references, false);
+ }
+ if(parentSymbol == null)
+ break;
+ else {
+ parentScope = parentSymbol;
+ offset += token.length()+ DOUBLE_COLON.length();
+ }
+ }
+
+ if((parentScope != null) &&
+ ( (parentScope.getType() == TypeInfo.t_class)
+ || (parentScope.getType() == TypeInfo.t_struct)
+ || (parentScope.getType() == TypeInfo.t_union))
+ ){
+ IASTScope fieldParentScope = (IASTScope)parentScope.getASTExtension().getPrimaryDeclaration();
+ return createField(fieldParentScope, fieldName,isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern,
+ isRegister, isStatic, startingOffset, offset, constructorExpression, ASTAccessVisibility.PRIVATE, references);
+ }
+ }
+
ISymbol newSymbol = cloneSimpleTypeSymbol(name, abstractDeclaration, references);
setVariableTypeInfoBits(
isAuto,
@@ -1862,16 +1929,28 @@
isStatic,
newSymbol);
setPointerOperators( newSymbol, abstractDeclaration.getPointerOperators(), abstractDeclaration.getArrayModifiers() );
+
+ newSymbol.setIsForwardDeclaration(isStatic);
+ boolean previouslyDeclared = false;
+ if(!isStatic){
+ ISymbol variableDeclaration = (ISymbol) lookupQualifiedName(ownerScope, name, new ArrayList(), false);
+
+ if( variableDeclaration != null )
+ {
+ variableDeclaration.setTypeSymbol( newSymbol );
+ previouslyDeclared = true;
+ }
+ }
try
{
- scopeToSymbol(scope).addSymbol( newSymbol );
+ ownerScope.addSymbol( newSymbol );
}
catch (ParserSymbolTableException e)
{
// TODO Auto-generated catch block
}
- ASTVariable variable = new ASTVariable( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references, constructorExpression );
+ ASTVariable variable = new ASTVariable( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references, constructorExpression, previouslyDeclared );
try
{
attachSymbolExtension(newSymbol, variable );
@@ -1931,6 +2010,25 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createField(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, boolean, org.eclipse.cdt.core.parser.ast.IASTInitializerClause, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, boolean, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility)
*/
+ public IASTField createField(
+ IASTScope scope,
+ String name,
+ boolean isAuto,
+ IASTInitializerClause initializerClause,
+ IASTExpression bitfieldExpression,
+ IASTAbstractDeclaration abstractDeclaration,
+ boolean isMutable,
+ boolean isExtern,
+ boolean isRegister,
+ boolean isStatic,
+ int startingOffset,
+ int nameOffset,
+ IASTExpression constructorExpression, ASTAccessVisibility visibility) throws ASTSemanticException
+ {
+ return createField(scope, name,isAuto, initializerClause, bitfieldExpression, abstractDeclaration, isMutable, isExtern,
+ isRegister, isStatic, startingOffset, nameOffset, constructorExpression, visibility, null);
+ }
+
public IASTField createField(
IASTScope scope,
String name,
@@ -1944,9 +2042,14 @@
boolean isStatic,
int startingOffset,
int nameOffset,
- IASTExpression constructorExpression, ASTAccessVisibility visibility) throws ASTSemanticException
+ IASTExpression constructorExpression,
+ ASTAccessVisibility visibility,
+ List references) throws ASTSemanticException
{
- List references = new ArrayList();
+ IContainerSymbol ownerScope = scopeToSymbol( scope );
+
+ if(references == null)
+ references = new ArrayList();
ISymbol newSymbol = cloneSimpleTypeSymbol(name, abstractDeclaration, references);
setVariableTypeInfoBits(
isAuto,
@@ -1958,16 +2061,32 @@
newSymbol);
setPointerOperators( newSymbol, abstractDeclaration.getPointerOperators(), abstractDeclaration.getArrayModifiers() );
+ newSymbol.setIsForwardDeclaration(isStatic);
+ boolean previouslyDeclared = false;
+ if(!isStatic){
+ List fieldReferences = new ArrayList();
+ ISymbol fieldDeclaration = lookupQualifiedName(ownerScope, name, fieldReferences, false);
+
+ if( fieldDeclaration != null )
+ {
+ previouslyDeclared = true;
+ fieldDeclaration.setTypeSymbol( newSymbol );
+ // set the definition visibility = declaration visibility
+ ASTReference reference = (ASTReference) fieldReferences.iterator().next();
+ visibility = ((IASTField)reference.getReferencedElement()).getVisiblity();
+ }
+ }
+
try
{
- scopeToSymbol(scope).addSymbol( newSymbol );
+ ownerScope.addSymbol( newSymbol );
}
catch (ParserSymbolTableException e)
{
throw new ASTSemanticException();
}
- ASTField field = new ASTField( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references, constructorExpression, visibility );
+ ASTField field = new ASTField( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, nameOffset, references, previouslyDeclared, constructorExpression, visibility );
try
{
attachSymbolExtension(newSymbol, field );
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java,v
retrieving revision 1.34
diff -u -r1.34 QuickParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 15 Sep 2003 22:50:25 -0000 1.34
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 23 Sep 2003 19:52:50 -0000
@@ -188,7 +188,7 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
*/
- public IASTFunction createFunction(IASTScope scope, String name, int nameEndOffset, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isFunctionDefinition )
+ public IASTFunction createFunction(IASTScope scope, String name, int nameEndOffset, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, List constructorChain, boolean isFunctionDefinition )
{
return new ASTFunction(scope, name, nameEndOffset, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate );
}
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.106
diff -u -r1.106 ChangeLog
--- ChangeLog 23 Sep 2003 15:17:03 -0000 1.106
+++ ChangeLog 23 Sep 2003 19:53:09 -0000
@@ -1,3 +1,7 @@
+2003-09-23 Hoda Amer
+ Added CompleteParseASTTest.testBug43373()
+ Added QuickParseASTTests.testBug43371()
+
2003-09-22 Bogdan Gheorghe
- modified CompletionProposalsTests, BaseSearchTest
to avoid using isEnabled for the IndexManager
Index: parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java,v
retrieving revision 1.30
diff -u -r1.30 CompleteParseASTTest.java
--- parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java 16 Sep 2003 14:45:34 -0000 1.30
+++ parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java 23 Sep 2003 19:53:10 -0000
@@ -773,5 +773,28 @@
for( int j =0; j < 4; ++j )
assertFalse( classOp.getNameOffset() == ((IASTReference)callback.getReferences().get(j)).getOffset() );
}
+ /**
+ * class A { static int x; } int A::x = 5;
+ */
+ public void testBug43373() throws Exception
+ {
+ try { // This is to prove that there are no exceptions
+ // Used to cause AST Semantic exception
+ Iterator i = parse( "class A { static int x; }; int A::x = 5;" ).getDeclarations();
+ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
+ Iterator j = getDeclarations(classA);
+ IASTField field1 = (IASTField) j.next();
+ // Note : this used to be considered a variable, not a field
+ IASTField field2 = (IASTField)i.next();
+
+ assertEquals( callback.getReferences().size(), 1 );
+ Iterator references = callback.getReferences().iterator();
+ assertEquals( ((IASTReference)references.next()).getReferencedElement(), classA );
+ assertTrue (field1.getVisiblity() == field2.getVisiblity());
+ }catch (Exception e){
+ fail();
+ }
+ }
+
}
Index: parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java,v
retrieving revision 1.19
diff -u -r1.19 QuickParseASTTests.java
--- parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java 15 Sep 2003 22:50:59 -0000 1.19
+++ parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.java 23 Sep 2003 19:53:11 -0000
@@ -1815,5 +1815,31 @@
{
parse("int *restrict ip_fn (void);", true, true, ParserLanguage.C).getDeclarations().next();
}
-
+ /**
+ * Test code: struct Example { Example(); Example(int); ~Example();};
+ * Purpose: tests a declaration in a class scope.
+ */
+ public void testBug43371 () throws Exception
+ {
+ // Parse and get the translaton unit
+ Writer code = new StringWriter();
+ code.write("struct Example { Example(); Example(int); ~Example();};");
+ IASTCompilationUnit cu = parse(code.toString());
+ Iterator i = cu.getDeclarations();
+ assertTrue(i.hasNext());
+ IASTAbstractTypeSpecifierDeclaration declaration =
+ (IASTAbstractTypeSpecifierDeclaration)i.next();
+ assertFalse(i.hasNext());
+ assertTrue( declaration.getTypeSpecifier() instanceof IASTClassSpecifier);
+ assertTrue(((IASTClassSpecifier)declaration.getTypeSpecifier()).getClassKind()== ASTClassKind.STRUCT);
+ Iterator j =((IASTClassSpecifier)declaration.getTypeSpecifier()).getDeclarations();
+ assertTrue(j.hasNext());
+ IASTMethod m1 = (IASTMethod)j.next();
+ IASTMethod m2 = (IASTMethod)j.next();
+ IASTMethod m3 = (IASTMethod)j.next();
+ assertFalse(j.hasNext());
+ assertTrue(m1.getVisiblity() == ASTAccessVisibility.PUBLIC);
+ assertTrue(m2.getVisiblity() == ASTAccessVisibility.PUBLIC);
+ assertTrue(m3.getVisiblity() == ASTAccessVisibility.PUBLIC);
+ }
}