Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2014-05-18 02:38:13 +0000
committerSergey Prigogin2014-05-18 19:14:17 +0000
commit17900f3f59a76ba5b8c0a4532dbf01c66d1d784e (patch)
tree8c10bee83b9679787ceb9432537c15a4e15b1a7d
parent10f84fd94bd681fcde13fa20fa42bbdd2045dd12 (diff)
downloadorg.eclipse.cdt-17900f3f59a76ba5b8c0a4532dbf01c66d1d784e.tar.gz
org.eclipse.cdt-17900f3f59a76ba5b8c0a4532dbf01c66d1d784e.tar.xz
org.eclipse.cdt-17900f3f59a76ba5b8c0a4532dbf01c66d1d784e.zip
Bug 409882 - Visibility of lambda with class owner
Change-Id: Ia16221cb441de535cad0b22786e2878e084fca3d Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/26783 Tested-by: Hudson CI Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java7
2 files changed, 23 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
index 56941e1d3e7..5b7e70cf050 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
@@ -1834,4 +1834,20 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
IVariable waldo = getBindingFromASTName("waldo", 5);
assertEquals(42, waldo.getInitialValue().numericalValue().longValue());
}
+
+ // struct function {
+ // template <typename T>
+ // function(T);
+ // };
+ //
+ // struct test {
+ // // These lambdas have the class 'test' as their owner.
+ // test(function f = [](int c){ return c; });
+ // function member = [](int c){ return c; };
+ // };
+
+ // int z;
+ public void testLambdaOwnedByClass() throws Exception {
+ checkBindings();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java
index 4c2e67faf26..ed2e8c03eb4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java
@@ -901,6 +901,13 @@ public class ClassTypeHelper {
return ICPPClassType.v_public; // Fallback visibility
}
}
+
+ // The concept of visibility does not apply to a lambda, which can end
+ // up having a class as its owner if they are used in the initializer
+ // of a field or a member function parameter.
+ if (member instanceof CPPClosureType) {
+ return ICPPClassType.v_public;
+ }
ICPPASTCompositeTypeSpecifier classDeclSpec = classType.getCompositeTypeSpecifier();
int visibility = getVisibility(classDeclSpec, member);

Back to the top