Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2010-08-18 04:55:38 -0400
committerMarkus Schorn2010-08-18 04:55:38 -0400
commitb124a1d6e04ed3bf0f7a535efa744351cea8b6a5 (patch)
tree5bcde1bf8d9ee4819c085c4eeeb40c2886c7d513
parentc339bd45c68b1faecafca21a517c1a9e5aa48df9 (diff)
downloadorg.eclipse.cdt-b124a1d6e04ed3bf0f7a535efa744351cea8b6a5.tar.gz
org.eclipse.cdt-b124a1d6e04ed3bf0f7a535efa744351cea8b6a5.tar.xz
org.eclipse.cdt-b124a1d6e04ed3bf0f7a535efa744351cea8b6a5.zip
Bug 322988: Updating parameter bindings for method specializatoins.
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java11
2 files changed, 19 insertions, 5 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 2c0804f739..f6b3f43e05 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -4139,4 +4139,15 @@ public class AST2TemplateTests extends AST2BaseTest {
final String code= getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP);
}
+
+ // template <typename T> class CT {
+ // void init();
+ // };
+ // void CT<int>::init(void) {
+ // }
+ public void testMethodSpecialization_322988() throws Exception {
+ final String code= getAboveComment();
+ parseAndCheckBindings(code, ParserLanguage.CPP);
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
index 46e9f8a966..3ab37ba43d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
+import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/**
@@ -222,12 +223,14 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
return;
}
IASTParameterDeclaration[] nps = fdtor.getParameters();
- for (int i = 0; i < nps.length; i++) {
+
+ // The lengths can be different, e.g.: f(void) and f().
+ final int end= Math.min(params.length, nps.length);
+ for (int i = 0; i < end; i++) {
final IParameter param = params[i];
if (param != null) {
IASTDeclarator dtor = nps[i].getDeclarator();
- while (dtor.getNestedDeclarator() != null)
- dtor = dtor.getNestedDeclarator();
+ dtor= ASTQueries.findInnermostDeclarator(dtor);
IASTName name = dtor.getName();
name.setBinding(param);
ASTInternal.addDeclaration(param, name);

Back to the top