1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +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:48:01 +02:00
parent be01bfb2ce
commit 4d758c0fc9
2 changed files with 22 additions and 6 deletions

View file

@ -9424,4 +9424,20 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(ctor instanceof ICPPConstructor); assertTrue(ctor instanceof ICPPConstructor);
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

@ -362,13 +362,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) {