summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-02-19 00:01:33 (EST)
committer Sergey Prigogin2013-02-20 12:37:58 (EST)
commitee08bee24b2ac0013f876fcb64ef6cebd8e35f4d (patch)
tree1847df8d6e065c788a7404e26266f76328d04650
parentf1542b27c6218771330775dd0820e737fcd0514e (diff)
downloadorg.eclipse.cdt-ee08bee24b2ac0013f876fcb64ef6cebd8e35f4d.zip
org.eclipse.cdt-ee08bee24b2ac0013f876fcb64ef6cebd8e35f4d.tar.gz
org.eclipse.cdt-ee08bee24b2ac0013f876fcb64ef6cebd8e35f4d.tar.bz2
Bug 401140 - NullPointerException in CPPTemplates.addDefaultArguments()refs/changes/66/10466/3
Change-Id: I05fa8a3935904cb1bd293348dcbf10810e677b5c Reviewed-on: https://git.eclipse.org/r/10466 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.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java2
2 files changed, 24 insertions, 0 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 5b5b5fe..81fee25 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
@@ -7271,4 +7271,26 @@ public class AST2TemplateTests extends AST2TestBase {
public void testRegression_399829() throws Exception {
parseAndCheckBindings();
}
+
+ // template <typename>
+ // struct Bind {};
+ // template <typename Func, typename ... BoundArgs>
+ // struct Bind_helper {
+ // typedef Bind<Func(BoundArgs...)> type;
+ // };
+ // template <typename Func, typename ... BoundArgs>
+ // typename Bind_helper<Func, BoundArgs...>::type
+ // bind(Func, BoundArgs...);
+ // struct S {
+ // template <typename T, typename U>
+ // void operator()(T, U);
+ // };
+ // int main() {
+ // S s;
+ // bind(s, 0, foo);
+ // }
+ public void testNPE_401140() throws Exception {
+ BindingAssertionHelper helper = new BindingAssertionHelper(getAboveComment(), true);
+ helper.assertProblem("bind(s, 0, foo)", "bind");
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
index 0069e67..c1ad1d0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
@@ -1103,6 +1103,7 @@ public class CPPTemplates {
ICPPTemplateArgument origArg = args[i];
ICPPTemplateArgument newArg;
if (origArg.isPackExpansion()) {
+ ICPPTemplateArgument unexpanded= origArg;
origArg= origArg.getExpansionPattern();
int packSize= determinePackSize(origArg, tpMap);
if (packSize == PACK_SIZE_FAIL || packSize == PACK_SIZE_NOT_FOUND) {
@@ -1118,6 +1119,7 @@ public class CPPTemplates {
if (!isValidArgument(newArg)) {
if (strict)
return null;
+ result[i + resultShift] = unexpanded;
newResult = result;
shift = 0;
break;