Skip to content

Commit

Permalink
Merge pull request #7270 from RazvanN7/Issue_16649
Browse files Browse the repository at this point in the history
Fix Issue 16649 - Header gen skips parens
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Oct 31, 2017
2 parents 7f808c8 + 11c6190 commit f344696
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ddmd/hdrgen.d
Expand Up @@ -2204,7 +2204,8 @@ public:
/* Despite precedence, we don't allow a<b<c expressions.
* They must be parenthesized.
*/
if (precedence[e.op] < pr || (pr == PREC.rel && precedence[e.op] == pr))
if (precedence[e.op] < pr || (pr == PREC.rel && precedence[e.op] == pr)
|| (pr >= PREC.or && pr <= PREC.and && precedence[e.op] == PREC.rel))
{
buf.writeByte('(');
e.accept(this);
Expand Down
8 changes: 8 additions & 0 deletions test/compilable/extra-files/header2.d
Expand Up @@ -150,3 +150,11 @@ align (true ? 2 : 3):
align:
int var2;
}

// 16649
void leFoo()()
{
sign = a == 2 ? false : (y < 0) ^ sign;
sign = a == 2 ? false : sign ^ (y < 0);
sign = 2 + 3 | 7 + 5;
}
6 changes: 6 additions & 0 deletions test/compilable/extra-files/header2.di
Expand Up @@ -108,3 +108,9 @@ align (1) struct S9766
align int var2;
}
}
void leFoo()()
{
sign = a == 2 ? false : (y < 0) ^ sign;
sign = a == 2 ? false : sign ^ (y < 0);
sign = 2 + 3 | 7 + 5;
}
6 changes: 6 additions & 0 deletions test/compilable/extra-files/header2i.di
Expand Up @@ -210,3 +210,9 @@ align (1) struct S9766
align int var2;
}
}
void leFoo()()
{
sign = a == 2 ? false : (y < 0) ^ sign;
sign = a == 2 ? false : sign ^ (y < 0);
sign = 2 + 3 | 7 + 5;
}

0 comments on commit f344696

Please sign in to comment.