Skip to content

Commit

Permalink
Unify diagnostic messages
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed May 25, 2014
1 parent dce5083 commit 3cc8a0c
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/func.c
Expand Up @@ -2128,7 +2128,7 @@ void FuncDeclaration::semantic3(Scope *sc)
if (setGC())
error("@nogc function allocates a closure with the GC");
else
printGCUsage(loc, "Using closure causes gc allocation");
printGCUsage(loc, "using closure causes GC allocation");
}

/* If function survived being marked as impure, then it is pure
Expand Down
22 changes: 11 additions & 11 deletions src/nogc.c
Expand Up @@ -85,12 +85,12 @@ class NOGCVisitor : public StoppableVisitor

if (f->setGC())
{
e->error("array literals in @nogc function %s may cause GC allocation",
e->error("array literal in @nogc function %s may cause GC allocation",
f->toChars());
err = true;
return;
}
f->printGCUsage(e->loc, "Array literals cause gc allocation");
f->printGCUsage(e->loc, "array literal may cause GC allocation");
}

void visit(AssocArrayLiteralExp *e)
Expand All @@ -104,7 +104,7 @@ class NOGCVisitor : public StoppableVisitor
err = true;
return;
}
f->printGCUsage(e->loc, "Associative array literals cause gc allocation");
f->printGCUsage(e->loc, "associative array literal may cause GC allocation");
}

void visit(NewExp *e)
Expand Down Expand Up @@ -135,7 +135,7 @@ class NOGCVisitor : public StoppableVisitor
err = true;
return;
}
f->printGCUsage(e->loc, "'new' causes gc allocation");
f->printGCUsage(e->loc, "'new' causes GC allocation");
}

void visit(DeleteExp *e)
Expand All @@ -153,7 +153,7 @@ class NOGCVisitor : public StoppableVisitor
err = true;
return;
}
f->printGCUsage(e->loc, "'delete' requires gc");
f->printGCUsage(e->loc, "'delete' requires GC");
}

void visit(IndexExp* e)
Expand All @@ -163,11 +163,11 @@ class NOGCVisitor : public StoppableVisitor
{
if (f->setGC())
{
e->error("indexing an associative array in @nogc function %s may cause gc allocation", f->toChars());
e->error("indexing an associative array in @nogc function %s may cause GC allocation", f->toChars());
err = true;
return;
}
f->printGCUsage(e->loc, "Indexing an associative array may cause gc allocation");
f->printGCUsage(e->loc, "indexing an associative array may cause GC allocation");
}
}

Expand All @@ -177,11 +177,11 @@ class NOGCVisitor : public StoppableVisitor
{
if (f->setGC())
{
e->error("Setting 'length' in @nogc function %s may cause GC allocation", f->toChars());
e->error("setting 'length' in @nogc function %s may cause GC allocation", f->toChars());
err = true;
return;
}
f->printGCUsage(e->loc, "Setting 'length' may cause gc allocation");
f->printGCUsage(e->loc, "setting 'length' may cause GC allocation");
}
}

Expand All @@ -193,7 +193,7 @@ class NOGCVisitor : public StoppableVisitor
err = true;
return;
}
f->printGCUsage(e->loc, "Concatenation may cause gc allocation");
f->printGCUsage(e->loc, "operator ~= may cause GC allocation");
}

void visit(CatExp *e)
Expand All @@ -204,7 +204,7 @@ class NOGCVisitor : public StoppableVisitor
err = true;
return;
}
f->printGCUsage(e->loc, "Concatenation may cause gc allocation");
f->printGCUsage(e->loc, "operator ~ may cause GC allocation");
}
};

Expand Down
32 changes: 16 additions & 16 deletions test/compilable/vgc1.d
Expand Up @@ -12,13 +12,13 @@ struct S5 { @nogc new(size_t); }
/*
TEST_OUTPUT:
---
compilable/vgc1.d(27): vgc: 'new' causes gc allocation
compilable/vgc1.d(29): vgc: 'new' causes gc allocation
compilable/vgc1.d(30): vgc: 'new' causes gc allocation
compilable/vgc1.d(32): vgc: 'new' causes gc allocation
compilable/vgc1.d(33): vgc: 'new' causes gc allocation
compilable/vgc1.d(34): vgc: 'new' causes gc allocation
compilable/vgc1.d(38): vgc: 'new' causes gc allocation
compilable/vgc1.d(27): vgc: 'new' causes GC allocation
compilable/vgc1.d(29): vgc: 'new' causes GC allocation
compilable/vgc1.d(30): vgc: 'new' causes GC allocation
compilable/vgc1.d(32): vgc: 'new' causes GC allocation
compilable/vgc1.d(33): vgc: 'new' causes GC allocation
compilable/vgc1.d(34): vgc: 'new' causes GC allocation
compilable/vgc1.d(38): vgc: 'new' causes GC allocation
---
*/

Expand All @@ -41,12 +41,12 @@ void testNew()
/*
TEST_OUTPUT:
---
compilable/vgc1.d(55): vgc: 'new' causes gc allocation
compilable/vgc1.d(57): vgc: 'new' causes gc allocation
compilable/vgc1.d(58): vgc: 'new' causes gc allocation
compilable/vgc1.d(60): vgc: 'new' causes gc allocation
compilable/vgc1.d(61): vgc: 'new' causes gc allocation
compilable/vgc1.d(62): vgc: 'new' causes gc allocation
compilable/vgc1.d(55): vgc: 'new' causes GC allocation
compilable/vgc1.d(57): vgc: 'new' causes GC allocation
compilable/vgc1.d(58): vgc: 'new' causes GC allocation
compilable/vgc1.d(60): vgc: 'new' causes GC allocation
compilable/vgc1.d(61): vgc: 'new' causes GC allocation
compilable/vgc1.d(62): vgc: 'new' causes GC allocation
---
*/

Expand All @@ -72,9 +72,9 @@ void testNewScope()
/*
TEST_OUTPUT:
---
compilable/vgc1.d(82): vgc: 'delete' requires gc
compilable/vgc1.d(83): vgc: 'delete' requires gc
compilable/vgc1.d(84): vgc: 'delete' requires gc
compilable/vgc1.d(82): vgc: 'delete' requires GC
compilable/vgc1.d(83): vgc: 'delete' requires GC
compilable/vgc1.d(84): vgc: 'delete' requires GC
---
*/
void testDelete(int* p, Object o, S1* s)
Expand Down
34 changes: 17 additions & 17 deletions test/compilable/vgc2.d
Expand Up @@ -6,14 +6,14 @@
/*
TEST_OUTPUT:
---
compilable/vgc2.d(21): vgc: Concatenation may cause gc allocation
compilable/vgc2.d(22): vgc: Concatenation may cause gc allocation
compilable/vgc2.d(23): vgc: Concatenation may cause gc allocation
compilable/vgc2.d(25): vgc: Concatenation may cause gc allocation
compilable/vgc2.d(26): vgc: Concatenation may cause gc allocation
compilable/vgc2.d(27): vgc: Concatenation may cause gc allocation
compilable/vgc2.d(28): vgc: Concatenation may cause gc allocation
compilable/vgc2.d(29): vgc: Concatenation may cause gc allocation
compilable/vgc2.d(21): vgc: operator ~ may cause GC allocation
compilable/vgc2.d(22): vgc: operator ~ may cause GC allocation
compilable/vgc2.d(23): vgc: operator ~ may cause GC allocation
compilable/vgc2.d(25): vgc: operator ~ may cause GC allocation
compilable/vgc2.d(26): vgc: operator ~ may cause GC allocation
compilable/vgc2.d(27): vgc: operator ~ may cause GC allocation
compilable/vgc2.d(28): vgc: operator ~ may cause GC allocation
compilable/vgc2.d(29): vgc: operator ~ may cause GC allocation
---
*/
void testCat(int[] a, string s)
Expand All @@ -38,9 +38,9 @@ void testCat(int[] a, string s)
/*
TEST_OUTPUT:
---
compilable/vgc2.d(48): vgc: Concatenation may cause gc allocation
compilable/vgc2.d(50): vgc: Concatenation may cause gc allocation
compilable/vgc2.d(51): vgc: Concatenation may cause gc allocation
compilable/vgc2.d(48): vgc: operator ~= may cause GC allocation
compilable/vgc2.d(50): vgc: operator ~= may cause GC allocation
compilable/vgc2.d(51): vgc: operator ~= may cause GC allocation
---
*/
void testCatAssign(int[] a, string s)
Expand All @@ -58,8 +58,8 @@ int* barA();
/*
TEST_OUTPUT:
---
compilable/vgc2.d(70): vgc: Array literals cause gc allocation
compilable/vgc2.d(71): vgc: Array literals cause gc allocation
compilable/vgc2.d(70): vgc: array literal may cause GC allocation
compilable/vgc2.d(71): vgc: array literal may cause GC allocation
---
*/
void testArray()
Expand All @@ -76,8 +76,8 @@ void testArray()
/*
TEST_OUTPUT:
---
compilable/vgc2.d(87): vgc: Associative array literals cause gc allocation
compilable/vgc2.d(88): vgc: Associative array literals cause gc allocation
compilable/vgc2.d(87): vgc: associative array literal may cause GC allocation
compilable/vgc2.d(88): vgc: associative array literal may cause GC allocation
---
*/
void testAssocArray()
Expand All @@ -93,8 +93,8 @@ void testAssocArray()
/*
TEST_OUTPUT:
---
compilable/vgc2.d(102): vgc: Indexing an associative array may cause gc allocation
compilable/vgc2.d(103): vgc: Indexing an associative array may cause gc allocation
compilable/vgc2.d(102): vgc: indexing an associative array may cause GC allocation
compilable/vgc2.d(103): vgc: indexing an associative array may cause GC allocation
---
*/
void testIndex(int[int] aa)
Expand Down
10 changes: 5 additions & 5 deletions test/compilable/vgc3.d
Expand Up @@ -6,9 +6,9 @@
/*
TEST_OUTPUT:
---
compilable/vgc3.d(16): vgc: Setting 'length' may cause gc allocation
compilable/vgc3.d(17): vgc: Setting 'length' may cause gc allocation
compilable/vgc3.d(18): vgc: Setting 'length' may cause gc allocation
compilable/vgc3.d(16): vgc: setting 'length' may cause GC allocation
compilable/vgc3.d(17): vgc: setting 'length' may cause GC allocation
compilable/vgc3.d(18): vgc: setting 'length' may cause GC allocation
---
*/
void testArrayLength(int[] a)
Expand Down Expand Up @@ -44,8 +44,8 @@ void testCall()
/*
TEST_OUTPUT:
---
compilable/vgc3.d(51): vgc: Using closure causes gc allocation
compilable/vgc3.d(63): vgc: Using closure causes gc allocation
compilable/vgc3.d(51): vgc: using closure causes GC allocation
compilable/vgc3.d(63): vgc: using closure causes GC allocation
---
*/
auto testClosure1()
Expand Down
8 changes: 4 additions & 4 deletions test/fail_compilation/nogc2.d
Expand Up @@ -58,8 +58,8 @@ fail_compilation/nogc2.d(51): Error: cannot use operator ~= in @nogc function te
/*
TEST_OUTPUT:
---
fail_compilation/nogc2.d(70): Error: array literals in @nogc function testArray may cause GC allocation
fail_compilation/nogc2.d(71): Error: array literals in @nogc function testArray may cause GC allocation
fail_compilation/nogc2.d(70): Error: array literal in @nogc function testArray may cause GC allocation
fail_compilation/nogc2.d(71): Error: array literal in @nogc function testArray may cause GC allocation
---
*/
@nogc void testArray()
Expand Down Expand Up @@ -93,8 +93,8 @@ fail_compilation/nogc2.d(88): Error: associative array literal in @nogc function
/*
TEST_OUTPUT:
---
fail_compilation/nogc2.d(102): Error: indexing an associative array in @nogc function testIndex may cause gc allocation
fail_compilation/nogc2.d(103): Error: indexing an associative array in @nogc function testIndex may cause gc allocation
fail_compilation/nogc2.d(102): Error: indexing an associative array in @nogc function testIndex may cause GC allocation
fail_compilation/nogc2.d(103): Error: indexing an associative array in @nogc function testIndex may cause GC allocation
---
*/
@nogc void testIndex(int[int] aa)
Expand Down
6 changes: 3 additions & 3 deletions test/fail_compilation/nogc3.d
Expand Up @@ -6,9 +6,9 @@
/*
TEST_OUTPUT:
---
fail_compilation/nogc3.d(16): Error: Setting 'length' in @nogc function testArrayLength may cause GC allocation
fail_compilation/nogc3.d(17): Error: Setting 'length' in @nogc function testArrayLength may cause GC allocation
fail_compilation/nogc3.d(18): Error: Setting 'length' in @nogc function testArrayLength may cause GC allocation
fail_compilation/nogc3.d(16): Error: setting 'length' in @nogc function testArrayLength may cause GC allocation
fail_compilation/nogc3.d(17): Error: setting 'length' in @nogc function testArrayLength may cause GC allocation
fail_compilation/nogc3.d(18): Error: setting 'length' in @nogc function testArrayLength may cause GC allocation
---
*/
@nogc void testArrayLength(int[] a)
Expand Down

0 comments on commit 3cc8a0c

Please sign in to comment.