| author | Thomas Corbat | 2012-08-18 22:58:40 (EDT) |
|---|---|---|
| committer | Sergey Prigogin | 2012-08-18 23:04:46 (EDT) |
| commit | 6cb90b0eb6e0d125a62b6294e524df8f91552dc0 (patch) (side-by-side diff) | |
| tree | 9e0e5c74ed77d606efe78e132dfcef2217d5deb1 | |
| parent | fa72bc94a09d0a1a462231183c023cb7ec00e651 (diff) | |
| download | org.eclipse.cdt-6cb90b0eb6e0d125a62b6294e524df8f91552dc0.zip org.eclipse.cdt-6cb90b0eb6e0d125a62b6294e524df8f91552dc0.tar.gz org.eclipse.cdt-6cb90b0eb6e0d125a62b6294e524df8f91552dc0.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 2c96003..de19728 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); } |

