A broken diagnostic is issued for the following invalid code snippet since GCC 4.0.0: ================================ void foo(char **p, char **q) { (p - q)(); } ================================ With GCC 4.0.x we got bug.c: In function 'foo': bug.c:3: error: called object '#'exact_div_expr' not supported by pp_c_expression#' is not a function which is already bad enough. But since GCC 4.1.0 it's even worse: #'exact_div_expr' not supported by pp_c_expression#'bug.c: In function 'foo': bug.c:3: error: called object is not a function Not only the exact_div_expr case should be fixed, but also the output order when we hit something unsupported. And, yes, there are more cases of unsupported expressions. How about the following? ================================ void foo(char *p, char *q) { (p < q ? p : q)(); } ================================ #'min_expr' not supported by pp_c_expression#'bug.c: In function 'foo': bug.c:3: error: called object is not a function ================================ void foo(double x, double y) { (x/y)(); } ================================ #'rdiv_expr' not supported by pp_c_expression#'bug.c: In function 'foo': bug.c:3: error: called object is not a function ================================ void foo(unsigned i, int j) { (i << j | i >> (32 - j))(); (i >> j | i << (32 - j))(); } ================================ #'lrotate_expr' not supported by pp_c_expression#'bug.c: In function 'foo': bug.c:3: error: called object is not a function #'rrotate_expr' not supported by pp_c_expression#'bug.c:4: error: called object is not a function
Closing 4.1 branch.
FYI, clang produces: t.c:3:3: error: called object is not a function or function pointer (p - q)(); ^~~~~~~~~ t.c:8:3: error: called object is not a function or function pointer (p < q ? p : q)(); ^~~~~~~~~~~~~~~~~
Closing 4.2 branch.
GCC 4.3.4 is being released, adjusting target milestone.
GCC 4.3.5 is being released, adjusting target milestone.
4.3 branch is being closed, moving to 4.4.7 target.
4.4 branch is being closed, moving to 4.5.4 target.
Author: manu Date: Sat Apr 21 14:53:21 2012 New Revision: 186652 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186652 Log: 2012-04-21 Manuel López-Ibáñez <manu@gcc.gnu.org> PR 35441 * c-typeck.c (inform_declaration): New. (build_function_call_vec): Do not pretty-print expressions when caret is enabled. (convert_arguments): Use inform_declaration. cp/ * typeck.c (cp_build_function_call_vec): Do not pretty-print expressions when caret is enabled. testsuite/ * c-c++-common/pr35441.C: New. Modified: trunk/gcc/ChangeLog trunk/gcc/c-typeck.c trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog
This is fixed when using -fdiagnostics-show-caret, which is the default. However, the underlying problem is still there, so I cannot be considered fixed.
Patch at https://gcc.gnu.org/ml/gcc-patches/2017-03/msg00498.html
Author: reichelt Date: Tue May 9 19:09:22 2017 New Revision: 247810 URL: https://gcc.gnu.org/viewcvs?rev=247810&root=gcc&view=rev Log: 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. Added: trunk/gcc/testsuite/gcc.dg/pr35441.c Modified: trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c-pretty-print.c trunk/gcc/testsuite/ChangeLog
Fixed on trunk for GCC 8.