From: Volker Reichelt Date: Tue, 9 May 2017 19:09:22 +0000 (+0000) Subject: re PR c/35441 (pretty-printer cannot handle some expressions) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=31c2d57d4a1439c8165ef95754ebc28bdc302166;p=gcc.git re PR c/35441 (pretty-printer cannot handle some expressions) PR c/35441 * c-pretty-print.c (c_pretty_printer::expression): Handle MAX_EXPR, MIN_EXPR, EXACT_DIV_EXPR, RDIV_EXPR, LROTATE_EXPR, RROTATE_EXPR. (c_pretty_printer::postfix_expression): Handle MAX_EXPR, MIN_EXPR. (c_pretty_printer::multiplicative_expression): Handle EXACT_DIV_EXPR, RDIV_EXPR. (pp_c_shift_expression): Handle LROTATE_EXPR, RROTATE_EXPR. * gcc.dg/pr35441.c: New test. From-SVN: r247810 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index e76a6289cc4..dd2cd519401 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,13 @@ +2017-05-09 Volker Reichelt + + PR c/35441 + * c-pretty-print.c (c_pretty_printer::expression): Handle MAX_EXPR, + MIN_EXPR, EXACT_DIV_EXPR, RDIV_EXPR, LROTATE_EXPR, RROTATE_EXPR. + (c_pretty_printer::postfix_expression): Handle MAX_EXPR, MIN_EXPR. + (c_pretty_printer::multiplicative_expression): Handle EXACT_DIV_EXPR, + RDIV_EXPR. + (pp_c_shift_expression): Handle LROTATE_EXPR, RROTATE_EXPR. + 2017-05-09 Marek Polacek PR c/80525 diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index 5d79519fa7d..fdb7b41f592 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -1551,6 +1551,14 @@ c_pretty_printer::postfix_expression (tree e) : "__builtin_islessgreater"); goto two_args_fun; + case MAX_EXPR: + pp_c_ws_string (this, "max"); + goto two_args_fun; + + case MIN_EXPR: + pp_c_ws_string (this, "min"); + goto two_args_fun; + two_args_fun: pp_c_left_paren (this); expression (TREE_OPERAND (e, 0)); @@ -1829,6 +1837,8 @@ c_pretty_printer::multiplicative_expression (tree e) case MULT_EXPR: case TRUNC_DIV_EXPR: case TRUNC_MOD_EXPR: + case EXACT_DIV_EXPR: + case RDIV_EXPR: multiplicative_expression (TREE_OPERAND (e, 0)); pp_c_whitespace (this); if (code == MULT_EXPR) @@ -1890,9 +1900,13 @@ pp_c_shift_expression (c_pretty_printer *pp, tree e) { case LSHIFT_EXPR: case RSHIFT_EXPR: + case LROTATE_EXPR: + case RROTATE_EXPR: pp_c_shift_expression (pp, TREE_OPERAND (e, 0)); pp_c_whitespace (pp); - pp_string (pp, code == LSHIFT_EXPR ? "<<" : ">>"); + pp_string (pp, code == LSHIFT_EXPR ? "<<" : + code == RSHIFT_EXPR ? ">>" : + code == LROTATE_EXPR ? "<<<" : ">>>"); pp_c_whitespace (pp); pp_c_additive_expression (pp, TREE_OPERAND (e, 1)); break; @@ -2186,6 +2200,8 @@ c_pretty_printer::expression (tree e) case UNLT_EXPR: case UNGE_EXPR: case UNGT_EXPR: + case MAX_EXPR: + case MIN_EXPR: case ABS_EXPR: case CONSTRUCTOR: case COMPOUND_LITERAL_EXPR: @@ -2217,11 +2233,15 @@ c_pretty_printer::expression (tree e) case MULT_EXPR: case TRUNC_MOD_EXPR: case TRUNC_DIV_EXPR: + case EXACT_DIV_EXPR: + case RDIV_EXPR: multiplicative_expression (e); break; case LSHIFT_EXPR: case RSHIFT_EXPR: + case LROTATE_EXPR: + case RROTATE_EXPR: pp_c_shift_expression (this, e); break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dac2f27b0dd..5906d94e25d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-05-09 Volker Reichelt + + PR c/35441 + * gcc.dg/pr35441.c: New test. + 2017-05-09 Martin Sebor PR testsuite/80643 diff --git a/gcc/testsuite/gcc.dg/pr35441.c b/gcc/testsuite/gcc.dg/pr35441.c new file mode 100644 index 00000000000..2d48533f311 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr35441.c @@ -0,0 +1,26 @@ +/* PR c/35441 */ +/* { dg-do compile } */ +/* { dg-options "-fno-diagnostics-show-caret" } */ +/* { dg-bogus "not supported by" "" { target *-*-* } 0 } */ + +void foo1(char **p, char **q) +{ + (p - q)(); /* { dg-error "is not a function" } */ +} + +void foo2(double x, double y) +{ + (x/y)(); /* { dg-error "is not a function" } */ +} + +void foo3(unsigned i, int j) +{ + (i << j | i >> (32 - j))(); /* { dg-error "is not a function" } */ + (i >> j | i << (32 - j))(); /* { dg-error "is not a function" } */ +} + +void foo4(char *p, char *q) +{ + (p < q ? p : q)(); /* { dg-error "is not a function" } */ + (p > q ? p : q)(); /* { dg-error "is not a function" } */ +}