From: Marek Polacek Date: Fri, 23 Mar 2018 13:45:49 +0000 (+0000) Subject: re PR c++/85045 (ICE+SIGILL on valid C++ code: cxx_pretty_printer::postfix_expressio... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=889a3a30d0aea481e3452b0f2e25d0c4657b2f21;p=gcc.git re PR c++/85045 (ICE+SIGILL on valid C++ code: cxx_pretty_printer::postfix_expression(tree_node*) (), at cp/cxx-pretty-print.c:482) PR c++/85045 * c-pretty-print.c (c_pretty_printer::multiplicative_expression) : 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. From-SVN: r258804 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 25ed91f2089..f728311310a 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2018-03-23 Marek Polacek + + PR c++/85045 + * c-pretty-print.c (c_pretty_printer::multiplicative_expression) + : Tweak condition. + 2018-03-20 Eric Botcazou * c-ada-spec.c (pp_ada_tree_identifier): Deal specifically with _Bool. diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index c9dd8aefff9..dc76c9957d3 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -1841,7 +1841,7 @@ c_pretty_printer::multiplicative_expression (tree e) pp_c_whitespace (this); if (code == MULT_EXPR) pp_c_star (this); - else if (code == TRUNC_DIV_EXPR) + else if (code != TRUNC_MOD_EXPR) pp_slash (this); else pp_modulo (this); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e04eae18a44..ddda091b5fd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-03-23 Marek Polacek + + PR c++/85045 + * 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. + 2018-03-23 Ville Voutilainen Implement P0962 diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index ca99997f5e1..9a5545cb5cc 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -899,11 +899,13 @@ cxx_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_space (this); if (code == MULT_EXPR) pp_star (this); - else if (code == TRUNC_DIV_EXPR) + else if (code != TRUNC_MOD_EXPR) pp_slash (this); else pp_modulo (this); @@ -1113,6 +1115,8 @@ cxx_pretty_printer::expression (tree t) case MULT_EXPR: case TRUNC_DIV_EXPR: case TRUNC_MOD_EXPR: + case EXACT_DIV_EXPR: + case RDIV_EXPR: multiplicative_expression (t); break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 88abac8faeb..fe12bbe38ce 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,10 @@ PR c++/85033 * g++.dg/ext/builtin-offsetof2.C: New test. + PR c++/85045 + * g++.dg/cpp0x/Wnarrowing5.C: New test. + * gcc.dg/pr85045.c: New test. + 2018-03-23 Eric Botcazou PR debug/85020 diff --git a/gcc/testsuite/g++.dg/cpp0x/Wnarrowing5.C b/gcc/testsuite/g++.dg/cpp0x/Wnarrowing5.C new file mode 100644 index 00000000000..d2abf03313e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wnarrowing5.C @@ -0,0 +1,11 @@ +// PR c++/85045 +// { dg-do compile { target c++11 } } + +typedef struct tt { + unsigned short h; +} tt; + +void mainScreen(float a) +{ + tt numlrect = {int(100/a)}; // { dg-error "narrowing conversion" } +} diff --git a/gcc/testsuite/gcc.dg/pr85045.c b/gcc/testsuite/gcc.dg/pr85045.c new file mode 100644 index 00000000000..8c4a7aa36a4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr85045.c @@ -0,0 +1,9 @@ +/* PR c/85045 */ +/* { dg-do compile } */ +/* { dg-options "-fno-diagnostics-show-caret" } */ + +void +f (double a, double b) +{ + (a / b) (); /* { dg-error "called object .a / b. is not a function or function pointer" } */ +}