Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarkus Schorn2011-07-20 08:01:49 -0400
committerMarkus Schorn2011-07-20 08:01:49 -0400
commitd226e960f9c1b40edd2dadefa005d092d1831fdf (patch)
tree40b0a302267962d58583132e74656395a4d46983 /core
parent34fdfb11964bdd89930641b0bff118f089fdb126 (diff)
downloadorg.eclipse.cdt-d226e960f9c1b40edd2dadefa005d092d1831fdf.tar.gz
org.eclipse.cdt-d226e960f9c1b40edd2dadefa005d092d1831fdf.tar.xz
org.eclipse.cdt-d226e960f9c1b40edd2dadefa005d092d1831fdf.zip
Bug 351609: Adjust parameter types in instantiated function type.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java2
3 files changed, 22 insertions, 1 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 bb429562e6..3e1bc2db25 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
@@ -5402,4 +5402,18 @@ public class AST2TemplateTests extends AST2BaseTest {
public void testAddressOfMethodForInstantiation_Bug344310() throws Exception {
parseAndCheckBindings();
}
+
+ // template<typename Arg> struct Callback {
+ // Callback(void (*function)(Arg arg)) {}
+ // };
+ //
+ // void Subscribe(const Callback<const int>& callback){}
+ // void CallMe(const int){}
+ //
+ // int test() {
+ // Subscribe(Callback<const int>(&CallMe)); // invalid arguments, symbol not
+ // }
+ public void testParameterAdjustementInInstantiatedFunctionType_351609() throws Exception {
+ parseAndCheckBindings();
+ }
}
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 a8c9c6cb1b..cb5e138902 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
@@ -1054,6 +1054,13 @@ public class CPPTemplates {
if (ret == r && params == ps) {
return type;
}
+ // The parameter types need to be adjusted.
+ for (int i=0; i<params.length; i++) {
+ IType p= params[i];
+ if (!isDependentType(p)) {
+ params[i]= CPPVisitor.adjustParameterType(p, true);
+ }
+ }
return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
index 2599107a73..049f19d97f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
@@ -1723,7 +1723,7 @@ public class CPPVisitor extends ASTQueries {
* Adjusts the parameter type according to 8.3.5-3:
* cv-qualifiers are deleted, arrays and function types are converted to pointers.
*/
- private static IType adjustParameterType(final IType pt, boolean forFunctionType) {
+ static IType adjustParameterType(final IType pt, boolean forFunctionType) {
// bug 239975
IType t= SemanticUtil.getNestedType(pt, TDEF);
if (t instanceof IArrayType) {

Back to the top