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:
parent
fa72bc94a0
commit
6cb90b0eb6
2 changed files with 30 additions and 0 deletions
|
@ -11,6 +11,7 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
* Thomas Corbat (IFS)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
|
@ -9742,4 +9743,29 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertEquals(1, declarations.length);
|
assertEquals(1, declarations.length);
|
||||||
assertEquals(bh.findName("S", 1), declarations[0]);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* Mike Kucera (IBM)
|
* Mike Kucera (IBM)
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
* Thomas Corbat (IFS)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -2323,6 +2324,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
protected boolean isLegalWithoutDtor(IASTDeclSpecifier declSpec) {
|
protected boolean isLegalWithoutDtor(IASTDeclSpecifier declSpec) {
|
||||||
if (declSpec instanceof IASTElaboratedTypeSpecifier) {
|
if (declSpec instanceof IASTElaboratedTypeSpecifier) {
|
||||||
return ((IASTElaboratedTypeSpecifier) declSpec).getKind() != IASTElaboratedTypeSpecifier.k_enum;
|
return ((IASTElaboratedTypeSpecifier) declSpec).getKind() != IASTElaboratedTypeSpecifier.k_enum;
|
||||||
|
} else if (declSpec instanceof ICPPASTNamedTypeSpecifier &&
|
||||||
|
((ICPPASTNamedTypeSpecifier) declSpec).isFriend()) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.isLegalWithoutDtor(declSpec);
|
return super.isLegalWithoutDtor(declSpec);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue