1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 380141 - Support for Extended Friend Declarations

Syntactic recognition of extended friend declarations. Approach is to
allow declarations to have no declarator if they are named type
specifiers and have friend as a declaration specifier.

Change-Id: Id49afaadc4fd8b1cd10b398977ca6db252a9e799
This commit is contained in:
Thomas Corbat 2012-08-18 19:58:40 -07:00 committed by Sergey Prigogin
parent 59866cf812
commit 99590ef089
2 changed files with 30 additions and 0 deletions

View file

@ -11,6 +11,7 @@
* Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian)
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
@ -9742,4 +9743,29 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(1, declarations.length);
assertEquals(bh.findName("S", 1), declarations[0]);
}
// struct F {};
// struct S {
// friend F;
// };
public void testFriendClass() throws Exception {
parseAndCheckBindings();
}
// struct F {};
// typedef F T;
// struct S {
// friend T;
// };
public void testFriendTypedef() throws Exception {
parseAndCheckBindings();
}
// template<typename P>
// struct T {
// friend P;
// };
public void testFriendTemplateParameter() throws Exception {
parseAndCheckBindings();
}
}

View file

@ -13,6 +13,7 @@
* Mike Kucera (IBM)
* Andrew Ferguson (Symbian)
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -2323,6 +2324,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected boolean isLegalWithoutDtor(IASTDeclSpecifier declSpec) {
if (declSpec instanceof IASTElaboratedTypeSpecifier) {
return ((IASTElaboratedTypeSpecifier) declSpec).getKind() != IASTElaboratedTypeSpecifier.k_enum;
} else if (declSpec instanceof ICPPASTNamedTypeSpecifier &&
((ICPPASTNamedTypeSpecifier) declSpec).isFriend()) {
return true;
}
return super.isLegalWithoutDtor(declSpec);
}