Skip to content

Commit 317cd23

Browse files
author
mpolacek
committed
PR c++/85045
* c-pretty-print.c (c_pretty_printer::multiplicative_expression) <case RDIV_EXPR>: Tweak condition. * cxx-pretty-print.c (cxx_pretty_printer::multiplicative_expression): Handle EXACT_DIV_EXPR and RDIV_EXPR. Tweak condition. (cxx_pretty_printer::expression): Handle EXACT_DIV_EXPR and RDIV_EXPR. * g++.dg/cpp0x/Wnarrowing5.C: New test. * gcc.dg/pr85045.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258804 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent d61fac4 commit 317cd23

File tree

7 files changed

+43
-2
lines changed

7 files changed

+43
-2
lines changed

gcc/c-family/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2018-03-23 Marek Polacek <[email protected]>
2+
3+
PR c++/85045
4+
* c-pretty-print.c (c_pretty_printer::multiplicative_expression)
5+
<case RDIV_EXPR>: Tweak condition.
6+
17
2018-03-20 Eric Botcazou <[email protected]>
28

39
* c-ada-spec.c (pp_ada_tree_identifier): Deal specifically with _Bool.

gcc/c-family/c-pretty-print.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ c_pretty_printer::multiplicative_expression (tree e)
18411841
pp_c_whitespace (this);
18421842
if (code == MULT_EXPR)
18431843
pp_c_star (this);
1844-
else if (code == TRUNC_DIV_EXPR)
1844+
else if (code != TRUNC_MOD_EXPR)
18451845
pp_slash (this);
18461846
else
18471847
pp_modulo (this);

gcc/cp/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2018-03-23 Marek Polacek <[email protected]>
2+
3+
PR c++/85045
4+
* cxx-pretty-print.c (cxx_pretty_printer::multiplicative_expression):
5+
Handle EXACT_DIV_EXPR and RDIV_EXPR. Tweak condition.
6+
(cxx_pretty_printer::expression): Handle EXACT_DIV_EXPR and RDIV_EXPR.
7+
18
2018-03-23 Ville Voutilainen <[email protected]>
29

310
Implement P0962

gcc/cp/cxx-pretty-print.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,11 +899,13 @@ cxx_pretty_printer::multiplicative_expression (tree e)
899899
case MULT_EXPR:
900900
case TRUNC_DIV_EXPR:
901901
case TRUNC_MOD_EXPR:
902+
case EXACT_DIV_EXPR:
903+
case RDIV_EXPR:
902904
multiplicative_expression (TREE_OPERAND (e, 0));
903905
pp_space (this);
904906
if (code == MULT_EXPR)
905907
pp_star (this);
906-
else if (code == TRUNC_DIV_EXPR)
908+
else if (code != TRUNC_MOD_EXPR)
907909
pp_slash (this);
908910
else
909911
pp_modulo (this);
@@ -1113,6 +1115,8 @@ cxx_pretty_printer::expression (tree t)
11131115
case MULT_EXPR:
11141116
case TRUNC_DIV_EXPR:
11151117
case TRUNC_MOD_EXPR:
1118+
case EXACT_DIV_EXPR:
1119+
case RDIV_EXPR:
11161120
multiplicative_expression (t);
11171121
break;
11181122

gcc/testsuite/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
PR c++/85033
44
* g++.dg/ext/builtin-offsetof2.C: New test.
55

6+
PR c++/85045
7+
* g++.dg/cpp0x/Wnarrowing5.C: New test.
8+
* gcc.dg/pr85045.c: New test.
9+
610
2018-03-23 Eric Botcazou <[email protected]>
711

812
PR debug/85020
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// PR c++/85045
2+
// { dg-do compile { target c++11 } }
3+
4+
typedef struct tt {
5+
unsigned short h;
6+
} tt;
7+
8+
void mainScreen(float a)
9+
{
10+
tt numlrect = {int(100/a)}; // { dg-error "narrowing conversion" }
11+
}

gcc/testsuite/gcc.dg/pr85045.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* PR c/85045 */
2+
/* { dg-do compile } */
3+
/* { dg-options "-fno-diagnostics-show-caret" } */
4+
5+
void
6+
f (double a, double b)
7+
{
8+
(a / b) (); /* { dg-error "called object .a / b. is not a function or function pointer" } */
9+
}

0 commit comments

Comments
 (0)