| author | Thomas Corbat | 2012-08-18 22:58:40 (EDT) |
|---|---|---|
| committer | Sergey Prigogin | 2012-08-18 23:12:32 (EDT) |
| commit | 99590ef0892e005f3e89a3ce9bacd0ab37c37305 (patch) (side-by-side diff) | |
| tree | ed7f3d114596b534ec2e699ccd38720a3c839f5a | |
| parent | 59866cf812f5e035618fa3a5c31c7d107b250d52 (diff) | |
| download | org.eclipse.cdt-99590ef0892e005f3e89a3ce9bacd0ab37c37305.zip org.eclipse.cdt-99590ef0892e005f3e89a3ce9bacd0ab37c37305.tar.gz org.eclipse.cdt-99590ef0892e005f3e89a3ce9bacd0ab37c37305.tar.bz2 | |
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
2 files changed, 30 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 0c40d13..7465d5d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -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(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index 93f1881..0f2834e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -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); } |

