From 5a38707ce0a403273a6bbf894e01669372dadd49 Mon Sep 17 00:00:00 2001 From: k-hara Date: Tue, 10 Feb 2015 21:59:20 +0900 Subject: [PATCH] fix Issue 14163 - No line number for error with disabled class constructor --- src/func.c | 7 ++++++- test/fail_compilation/diag14163.d | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/fail_compilation/diag14163.d diff --git a/src/func.c b/src/func.c index 1ec056934933..52a9399f6185 100644 --- a/src/func.c +++ b/src/func.c @@ -1640,10 +1640,15 @@ void FuncDeclaration::semantic3(Scope *sc) sc2->callSuper = 0; // Insert implicit super() at start of fbody - if (!resolveFuncCall(Loc(), sc2, cd->baseClass->ctor, NULL, NULL, NULL, 1)) + FuncDeclaration *fd = resolveFuncCall(Loc(), sc2, cd->baseClass->ctor, NULL, NULL, NULL, 1); + if (!fd) { error("no match for implicit super() call in constructor"); } + else if (fd->storage_class & STCdisable) + { + error("cannot call super() implicitly because it is annotated with @disable"); + } else { Expression *e1 = new SuperExp(Loc()); diff --git a/test/fail_compilation/diag14163.d b/test/fail_compilation/diag14163.d new file mode 100644 index 000000000000..8fe63433eb6e --- /dev/null +++ b/test/fail_compilation/diag14163.d @@ -0,0 +1,19 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/diag14163.d(16): Error: constructor diag14163.Bar.this cannot call super() implicitly because it is annotated with @disable +--- +*/ + +class Foo +{ + @disable this(); +} + +class Bar : Foo +{ + @disable this(); + this(int i) {} +} + +void main() {}