Skip to content

Commit

Permalink
Apply review points by Andrej Mitrovic
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Feb 18, 2013
1 parent 9be3402 commit d2249f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/func.c
Expand Up @@ -297,8 +297,12 @@ void FuncDeclaration::semantic(Scope *sc)
if (isOverride() && !isVirtual())
error("cannot override a non-virtual function");

if ((f->isConst() || f->isImmutable() || f->isShared() || f->isWild()) && !(isThis() || isNested()))
error("without 'this' cannot be const/immutable/shared/inout");
if (!f->isNaked() && !(isThis() || isNested()))
{
OutBuffer buf;
MODtoBuffer(&buf, f->mod);
error("without 'this' cannot be %s", buf.toChars());
}

if (isAbstract() && isFinal())
error("cannot be both final and abstract");
Expand Down
12 changes: 6 additions & 6 deletions test/fail_compilation/fail9199.d
@@ -1,12 +1,12 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail9199.d(13): Error: function fail9199.fc without 'this' cannot be const/immutable/shared/inout
fail_compilation/fail9199.d(14): Error: function fail9199.fi without 'this' cannot be const/immutable/shared/inout
fail_compilation/fail9199.d(15): Error: function fail9199.fw without 'this' cannot be const/immutable/shared/inout
fail_compilation/fail9199.d(16): Error: function fail9199.fs without 'this' cannot be const/immutable/shared/inout
fail_compilation/fail9199.d(17): Error: function fail9199.fsc without 'this' cannot be const/immutable/shared/inout
fail_compilation/fail9199.d(18): Error: function fail9199.fsw without 'this' cannot be const/immutable/shared/inout
fail_compilation/fail9199.d(13): Error: function fail9199.fc without 'this' cannot be const
fail_compilation/fail9199.d(14): Error: function fail9199.fi without 'this' cannot be immutable
fail_compilation/fail9199.d(15): Error: function fail9199.fw without 'this' cannot be inout
fail_compilation/fail9199.d(16): Error: function fail9199.fs without 'this' cannot be shared
fail_compilation/fail9199.d(17): Error: function fail9199.fsc without 'this' cannot be shared const
fail_compilation/fail9199.d(18): Error: function fail9199.fsw without 'this' cannot be shared inout
---
*/

Expand Down

0 comments on commit d2249f5

Please sign in to comment.