1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 03:45:35 +02:00

Bug 350345: Typedef as class name for ctor with overloaded function pointer argument.

This commit is contained in:
Markus Schorn 2011-07-04 10:10:54 +02:00
parent fa9ba41575
commit f50bbd1819
2 changed files with 22 additions and 7 deletions

View file

@ -9436,4 +9436,19 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(1, ((ICPPConstructor) ctor).getType().getParameterTypes().length); assertEquals(1, ((ICPPConstructor) ctor).getType().getParameterTypes().length);
} }
// struct Foo {
// void Method(int) {}
// void Method() const {}
// };
// template<typename Arg> struct Callback {
// Callback(void (Foo::*function)(Arg arg)) {
// }
// };
// typedef Callback<int> MyCallback;
// void xx() {
// MyCallback x= MyCallback(&Foo::Method); // Invalid overload of 'Foo::Method'
// }
public void testTypedefAsClassNameWithFunctionPtrArgument_350345() throws Exception {
parseAndCheckBindings();
}
} }

View file

@ -361,13 +361,13 @@ public class CPPSemantics {
} }
} }
if (binding instanceof ICPPClassType) { if (binding instanceof IType) {
if (convertClassToConstructor(data.astName)) { IType t = getNestedType((IType) binding, TDEF);
if (binding instanceof IIndexBinding) { if (t instanceof ICPPClassType && convertClassToConstructor(data.astName)) {
binding= data.tu.mapToAST((ICPPClassType) binding); ICPPClassType cls= (ICPPClassType) t;
if (cls instanceof IIndexBinding) {
cls= data.tu.mapToAST(cls);
} }
ICPPClassType cls= (ICPPClassType) binding;
try { try {
if (data.astName instanceof ICPPASTTemplateId && cls instanceof ICPPClassTemplate) { if (data.astName instanceof ICPPASTTemplateId && cls instanceof ICPPClassTemplate) {
if (data.tu != null) { if (data.tu != null) {