From 92e5739ba6dabcc491fbc83af956a3d2057dea63 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Fri, 16 May 2014 02:16:35 -0400 Subject: [PATCH] Bug 434467 - Fix NPE caused by incorrect caching of enumerators Change-Id: I7b0df5ea7d7b89ac89c42e8dc4091b3d5bf944f2 Signed-off-by: Nathan Ridge Reviewed-on: https://git.eclipse.org/r/26696 Tested-by: Hudson CI Reviewed-by: Sergey Prigogin Tested-by: Sergey Prigogin --- .../tests/IndexCPPTemplateResolutionTest.java | 26 +++++++++++++++++++ .../core/pdom/dom/cpp/PDOMCPPEnumScope.java | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index f84ca590869..44390a4b466 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -2525,4 +2525,30 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa public void testSpecializationOfConstexprFunction_420995() throws Exception { checkBindings(); } + + // template + // class waldo { + // enum { + // X = sizeof(TYPE), + // Y = 1 + // }; + // + // int value = X && 1; + // }; + // + // template struct A {}; + // + // template + // struct impl : A::value> {}; + // + // template + // struct meta : impl::type {}; + // + // template <> + // struct meta {}; + + // int z; + public void testEnumerationWithMultipleEnumerators_434467() throws Exception { + checkBindings(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java index 3930bd5badb..ce4159f068c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumScope.java @@ -159,7 +159,7 @@ class PDOMCPPEnumScope implements ICPPEnumScope, IIndexScope { Reference> cached= (Reference>) pdom.getCachedResult(key); CharArrayMap map= cached == null ? null : cached.get(); if (map != null) { - map.put(enumType.getNameCharArray(), enumItem); + map.put(enumItem.getNameCharArray(), enumItem); } }