diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 52c2eb6ec98..68ac85f9228 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -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() diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java index d6b9d8e56a3..6aad65076d9 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java @@ -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(); + } } diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser index b493b794b1c..bbf02fca2e4 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser +++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser @@ -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 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java index f4853b6d01f..736671b1785 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/DerivableContainerSymbol.java @@ -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 ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java index 1090d667c01..c78104be4a3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java @@ -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;