Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTSymbolIteratorTest.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java6
2 files changed, 21 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTSymbolIteratorTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTSymbolIteratorTest.java
index 0aed7bbe757..18d60e51aa2 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTSymbolIteratorTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTSymbolIteratorTest.java
@@ -6,6 +6,8 @@
*/
package org.eclipse.cdt.core.parser.tests;
+import java.io.StringWriter;
+import java.io.Writer;
import java.util.Iterator;
import java.util.NoSuchElementException;
@@ -22,6 +24,7 @@ import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
+import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
import org.eclipse.cdt.core.parser.ast.IASTField;
@@ -352,4 +355,19 @@ public class CompleteParseASTSymbolIteratorTest extends CompleteParseBaseTest {
IASTUsingDeclaration using = (IASTUsingDeclaration) i.next();
assertFalse( i.hasNext() );
}
+
+ public void testBug75482() throws Exception{
+ Writer writer = new StringWriter();
+ writer.write( "class A { friend class B * helper(); };" ); //$NON-NLS-1$
+ Iterator i = parse( writer.toString() ).getDeclarations();
+ IASTClassSpecifier A = (IASTClassSpecifier) i.next();
+ IASTFunction helper = (IASTFunction) i.next();
+ i = A.getDeclarations();
+ IASTElaboratedTypeSpecifier B = (IASTElaboratedTypeSpecifier) i.next();
+ assertFalse( i.hasNext() );
+
+ i = A.getFriends();
+ assertEquals( i.next(), helper );
+ assertFalse( i.hasNext() );
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
index 4842c5a70f2..2640508ee2e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
@@ -3236,7 +3236,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
ISymbol checkSymbol = null;
if (!isTemplateId) {
try {
- if (isFriend) {
+ if (isFriend && isForewardDecl) {
checkSymbol = ((IDerivableContainerSymbol) currentScopeSymbol)
.lookupForFriendship(newSymbolName);
} else {
@@ -3275,7 +3275,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
pstType);
checkSymbol.setIsForwardDeclaration(true);
try {
- if (isFriend) {
+ if (isFriend && isForewardDecl) {
((IDerivableContainerSymbol) originalScope).addFriend(checkSymbol);
} else {
if (!isTemplateId)
@@ -3296,7 +3296,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
references, isForewardDecl, filename);
attachSymbolExtension(checkSymbol, elab, !isForewardDecl);
return elab;
- } else if (isFriend) {
+ } else if (isFriend && isForewardDecl) {
((IDerivableContainerSymbol) originalScope).addFriend(checkSymbol);
}
if (checkSymbol != null) {

Back to the top