1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 01:35:39 +02:00

Type-deduction in function-type with reference type parameter, bug 281783.

This commit is contained in:
Markus Schorn 2009-07-02 11:52:34 +00:00
parent 8c5f3483fa
commit 3261b83ecb
2 changed files with 18 additions and 1 deletions

View file

@ -2270,6 +2270,17 @@ public class AST2TemplateTests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.CPP); parseAndCheckBindings(code, ParserLanguage.CPP);
} }
// template<class U> void f1(void(*f)(const U&)) {}
// void f2(const int& b){}
// void test() {
// f1(&f2); // problem on f1
// }
public void testSimplifiedFunctionTemplateWithFunctionPointer_281783() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP);
}
// template <class T> // template <class T>
// class A {}; // class A {};
// //
@ -2283,7 +2294,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// void test(A<B> x) { // void test(A<B> x) {
// f1(x, &f2); // f1(x, &f2);
// } // }
public void _testFunctionTemplateWithFunctionPointer_281783() throws Exception { public void testFunctionTemplateWithFunctionPointer_281783() throws Exception {
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
bh.assertNonProblem("f1(x, &f2);", 2, ICPPFunction.class); bh.assertNonProblem("f1(x, &f2);", 2, ICPPFunction.class);
} }

View file

@ -1599,6 +1599,12 @@ public class CPPTemplates {
} }
p = ((IPointerType) p).getType(); p = ((IPointerType) p).getType();
a = ((IPointerType) a).getType(); a = ((IPointerType) a).getType();
} else if (p instanceof ICPPReferenceType) {
if (!(a instanceof ICPPReferenceType)) {
return false;
}
p = ((ICPPReferenceType) p).getType();
a = ((ICPPReferenceType) a).getType();
} else if (p instanceof IQualifierType) { } else if (p instanceof IQualifierType) {
if (a instanceof IQualifierType) { if (a instanceof IQualifierType) {
a = ((IQualifierType) a).getType(); //TODO a = strip qualifiers from p out of a a = ((IQualifierType) a).getType(); //TODO a = strip qualifiers from p out of a