summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-03-03 04:46:27 (EST)
committerSergey Prigogin2013-03-03 20:39:00 (EST)
commitec7a25ee6da5561550013f21e6280d96edae5cd1 (patch)
tree638116c87aa1671d8e8a6a34dfa158a59e152722
parent664da446958fbbcce74938109b9fd82fa4f6d7ce (diff)
downloadorg.eclipse.cdt-ec7a25ee6da5561550013f21e6280d96edae5cd1.zip
org.eclipse.cdt-ec7a25ee6da5561550013f21e6280d96edae5cd1.tar.gz
org.eclipse.cdt-ec7a25ee6da5561550013f21e6280d96edae5cd1.tar.bz2
Bug 401743 - NullPointerException in EvalBinding.instantiate() - tpMaprefs/changes/05/10805/4
is null Change-Id: Ie33a99c582adccb44152033ca29ba0b88b5823ad Reviewed-on: https://git.eclipse.org/r/10805 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: 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/core/parser/tests/ast2/AST2TemplateTests.java67
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java8
2 files changed, 72 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
index a6fde67..fb81412 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
@@ -7364,4 +7364,71 @@ public class AST2TemplateTests extends AST2TestBase {
assertNotNull(barValue);
assertEquals(2, barValue.longValue());
}
+
+ // template <int...> struct tuple_indices {};
+ // template <int Sp, class IntTuple, int Ep>
+ // struct make_indices_imp;
+ // template <int Sp, int ...Indices, int Ep>
+ // struct make_indices_imp<Sp, tuple_indices<Indices...>, Ep> {
+ // typedef typename make_indices_imp<Sp + 1, tuple_indices<Indices..., Sp>, Ep>::type type;
+ // };
+ // template <int Ep, int ...Indices>
+ // struct make_indices_imp<Ep, tuple_indices<Indices...>, Ep> {
+ // typedef tuple_indices<Indices...> type;
+ // };
+ // template <int Ep, int Sp = 0>
+ // struct make_tuple_indices {
+ // typedef typename make_indices_imp<Sp, tuple_indices<>, Ep>::type type;
+ // };
+ // template <class ... Args>
+ // class async_func {
+ // void operator()() {
+ // typedef typename make_tuple_indices<1 + sizeof...(Args), 1>::type Index;
+ // }
+ // };
+ public void testVariadicTemplatesNPE_401743() throws Exception {
+ parseAndCheckBindings();
+ }
+
+ // template <typename T>
+ // struct A {};
+ //
+ // template <typename T>
+ // struct B {
+ // typedef int type;
+ // };
+ //
+ // template <class T, const T& V>
+ // struct C {};
+ //
+ // extern const char* const K = "";
+ //
+ // typedef A<C<const char*, K>> D;
+ //
+ // typedef B<D>::type E; // Problem on B<D>::type
+ public void testRegression_401743a() throws Exception {
+ parseAndCheckBindings();
+ }
+
+ // template <typename T>
+ // struct A {};
+ //
+ // template <typename T>
+ // struct B {
+ // typedef int type;
+ // };
+ //
+ // template <class T, const T& V>
+ // struct C {};
+ //
+ // class F {};
+ //
+ // extern F K;
+ //
+ // typedef A<C<F, K>> D;
+ //
+ // typedef B<D>::type E; // Problem on B<D>::type
+ public void testRegression_401743b() throws Exception {
+ parseAndCheckBindings();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
index cd6b3f0..1283f94 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
@@ -336,9 +336,11 @@ public class EvalBinding extends CPPDependentEvaluation {
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
IBinding origBinding = getBinding();
if (origBinding instanceof ICPPTemplateNonTypeParameter) {
- ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding, packOffset);
- if (argument != null && argument.isNonTypeValue()) {
- return argument.getNonTypeEvaluation();
+ if (tpMap != null) {
+ ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding, packOffset);
+ if (argument != null && argument.isNonTypeValue()) {
+ return argument.getNonTypeEvaluation();
+ }
}
} else if (origBinding instanceof ICPPParameter) {
ICPPParameter parameter = (ICPPParameter) origBinding;