1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

fix bug 59149

This commit is contained in:
Andrew Niefer 2004-04-19 21:27:59 +00:00
parent 62150f7451
commit 6b096ee976
5 changed files with 26 additions and 5 deletions

View file

@ -1,3 +1,6 @@
2004-04-19 Andrew Niefer
added parser/CompleteParseASTTest.testBug59149()
2004-04-19 Andrew Niefer
added parser/CompleteParseASTTemplateTest.test_14_7_3__5_ExplicitSpecialization()
uncommented & modified parser/ParserSymbolTableTemplateTests.test_14_7_3__5_ExplicitSpecialization()

View file

@ -1550,4 +1550,15 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
assertEquals( count, 2 );
}
public void testBug59149() throws Exception
{
Writer writer = new StringWriter();
writer.write( "class A{ friend class B; friend class B; };" );
writer.write( "class B{ };" );
Iterator i = parse( writer.toString() ).getDeclarations();
IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
IASTClassSpecifier B = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
}
}

View file

@ -1,3 +1,6 @@
2004-04-19 Andrew Niefer
fix bug 59149 [Parser] Redundant friend declaration fails parse
2004-04-19 Andrew Niefer
fix problems with explicit specialization

View file

@ -296,9 +296,6 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
* 7.3.1.2-3 If a friend declaration in a non-local class first declares a
* class or function, the friend class or function is a member of the
* innermost enclosing namespace.
*
* TODO: if/when the parser symbol table starts caring about visibility
* (public/protected/private) we will need to do more to record friendship.
*/
public void addFriend( ISymbol friend ){
//is this symbol already in the table?
@ -306,11 +303,16 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
if( containing == null ){
//its not, it goes in the innermost enclosing namespace
IContainerSymbol enclosing = getContainingSymbol();
boolean local = enclosing.isType( TypeInfo.t_constructor ) ||
enclosing.isType( TypeInfo.t_function ) ||
enclosing.isType( TypeInfo.t_block );
while( enclosing != null && !enclosing.isType( TypeInfo.t_namespace ) ){
enclosing = enclosing.getContainingSymbol();
}
friend.setIsInvisible( true );
friend.setIsInvisible( local );
friend.setIsForwardDeclaration( true );
try {
enclosing.addSymbol( friend );
@ -344,6 +346,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
}
}
data.stopAt = enclosing;
data.returnInvisibleSymbols = true;
ParserSymbolTable.lookup( data, this );
return ParserSymbolTable.resolveAmbiguities( data );

View file

@ -465,7 +465,7 @@ public class ParserSymbolTable {
symbol = ( temp != null ) ? temp : symbol;
}
if( !symbol.getIsInvisible() && checkType( data, symbol ) ){//, data.type, data.upperType ) ){
if( ( data.returnInvisibleSymbols || !symbol.getIsInvisible() ) && checkType( data, symbol ) ){
foundSymbol = symbol;
if( foundSymbol.isType( TypeInfo.t_function ) ){
@ -2109,6 +2109,7 @@ public class ParserSymbolTable {
public boolean usingDirectivesOnly = false;
public boolean forUserDefinedConversion = false;
public boolean exactFunctionsOnly = false;
public boolean returnInvisibleSymbols = false;
public Map foundItems = null;