From 6e6e34ab802d42607a4bf737809a552f965dd672 Mon Sep 17 00:00:00 2001 From: k-hara Date: Wed, 2 Oct 2013 17:34:32 +0900 Subject: [PATCH] fix Issue 10082 - ICE(e2ir.c) Multiple mixin template instantiations are not checked --- src/init.c | 17 +++++++++++++---- test/fail_compilation/fail10082.d | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 test/fail_compilation/fail10082.d diff --git a/src/init.c b/src/init.c index 6e7e954b5c65..28f10f893719 100644 --- a/src/init.c +++ b/src/init.c @@ -1060,17 +1060,17 @@ Type *ExpInitializer::inferType(Scope *sc) // Give error for overloaded function addresses if (exp->op == TOKsymoff) - { SymOffExp *se = (SymOffExp *)exp; + { + SymOffExp *se = (SymOffExp *)exp; if (se->hasOverloads && !se->var->isFuncDeclaration()->isUnique()) { exp->error("cannot infer type from overloaded function symbol %s", exp->toChars()); return Type::terror; } } - - // Give error for overloaded function addresses if (exp->op == TOKdelegate) - { DelegateExp *se = (DelegateExp *)exp; + { + DelegateExp *se = (DelegateExp *)exp; if (se->hasOverloads && se->func->isFuncDeclaration() && !se->func->isFuncDeclaration()->isUnique()) @@ -1079,6 +1079,15 @@ Type *ExpInitializer::inferType(Scope *sc) return Type::terror; } } + if (exp->op == TOKaddress) + { + AddrExp *ae = (AddrExp *)exp; + if (ae->e1->op == TOKoverloadset) + { + exp->error("cannot infer type from overloaded function symbol %s", exp->toChars()); + return Type::terror; + } + } Type *t = exp->type; if (!t) diff --git a/test/fail_compilation/fail10082.d b/test/fail_compilation/fail10082.d new file mode 100644 index 000000000000..fd3080109d44 --- /dev/null +++ b/test/fail_compilation/fail10082.d @@ -0,0 +1,25 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/fail10082.d(24): Error: cannot infer type from overloaded function symbol &foo +--- +*/ + +mixin template T() +{ + int foo() + { + return 0; + } +} + +class A +{ + mixin T; + mixin T; +} + +void main() +{ + auto x = &A.foo; +}