Skip to content

Commit

Permalink
fix Issue 12953 - Wrong alignment number in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jun 20, 2014
1 parent e3382dc commit 6ac993e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
20 changes: 18 additions & 2 deletions src/parse.c
Expand Up @@ -697,10 +697,26 @@ Dsymbols *Parser::parseDeclDefs(int once, Dsymbol **pLastDecl, PrefixAttributes

if (pAttrs->alignment != 0)
{
const char *s1 = "";
OutBuffer buf1;
if (n != STRUCTALIGN_DEFAULT)
{
buf1.printf("(%d)", n);
s1 = buf1.peekString();
}
if (pAttrs->alignment != n)
error("conflicting alignment attribute align(%d) and align(%d)", pAttrs->alignment, n);
{
OutBuffer buf2;
const char *s2 = "";
if (pAttrs->alignment != STRUCTALIGN_DEFAULT)
{
buf2.printf("(%d)", pAttrs->alignment);
s2 = buf2.peekString();
}
error("conflicting alignment attribute align%s and align%s", s2, s1);
}
else
error("redundant alignment attribute align(%d)", n);
error("redundant alignment attribute align%s", s1);
}

pAttrs->alignment = n;
Expand Down
14 changes: 10 additions & 4 deletions test/fail_compilation/parseStc2.d
Expand Up @@ -53,9 +53,15 @@ public private void f10() {}
/*
TEST_OUTPUT:
---
fail_compilation/parseStc2.d(60): Error: redundant alignment attribute align(1)
fail_compilation/parseStc2.d(61): Error: conflicting alignment attribute align(1) and align(2)
fail_compilation/parseStc2.d(63): Error: redundant alignment attribute align
fail_compilation/parseStc2.d(64): Error: redundant alignment attribute align(1)
fail_compilation/parseStc2.d(65): Error: conflicting alignment attribute align and align(1)
fail_compilation/parseStc2.d(66): Error: conflicting alignment attribute align(1) and align
fail_compilation/parseStc2.d(67): Error: conflicting alignment attribute align(1) and align(2)
---
*/
align(1) align(1) void f11() {}
align(1) align(2) void f12() {}
align align void f11() {}
align(1) align(1) void f12() {}
align align(1) void f13() {}
align(1) align void f14() {}
align(1) align(2) void f15() {}

0 comments on commit 6ac993e

Please sign in to comment.