diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0d5457d6501..94e92477e46 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2012-04-21 Manuel López-Ibáñez + + 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. + 2012-04-20 Jim Meyering * genmodes.c (make_complex_modes): Don't truncate a mode name of diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index e7060e2c3d2..2cd9572ec61 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2682,6 +2682,14 @@ build_function_call (location_t loc, tree function, tree params) return ret; } +/* Give a note about the location of the declaration of DECL. */ + +static void inform_declaration (tree decl) +{ + if (decl && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_BUILT_IN (decl))) + inform (DECL_SOURCE_LOCATION (decl), "declared here"); +} + /* Build a function call to function FUNCTION with parameters PARAMS. ORIGTYPES, if not NULL, is a vector of types; each element is either NULL or the original type of the corresponding element in @@ -2744,7 +2752,20 @@ build_function_call_vec (location_t loc, tree function, VEC(tree,gc) *params, if (!(TREE_CODE (fntype) == POINTER_TYPE && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE)) { - error_at (loc, "called object %qE is not a function", function); + if (!flag_diagnostics_show_caret) + error_at (loc, + "called object %qE is not a function or function pointer", + function); + else if (DECL_P (function)) + { + error_at (loc, + "called object %qD is not a function or function pointer", + function); + inform_declaration (function); + } + else + error_at (loc, + "called object is not a function or function pointer"); return error_mark_node; } @@ -3034,9 +3055,7 @@ convert_arguments (tree typelist, VEC(tree,gc) *values, else error_at (input_location, "too many arguments to function %qE", function); - - if (fundecl && !DECL_BUILT_IN (fundecl)) - inform (DECL_SOURCE_LOCATION (fundecl), "declared here"); + inform_declaration (fundecl); return parmnum; } @@ -3269,8 +3288,7 @@ convert_arguments (tree typelist, VEC(tree,gc) *values, { error_at (input_location, "too few arguments to function %qE", function); - if (fundecl && !DECL_BUILT_IN (fundecl)) - inform (DECL_SOURCE_LOCATION (fundecl), "declared here"); + inform_declaration (fundecl); return -1; } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e9af16c9f0a..479ff69416e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-04-21 Manuel López-Ibáñez + + PR 35441 + * typeck.c (cp_build_function_call_vec): Do not pretty-print + expressions when caret is enabled. + 2012-04-20 Jan Hubicka PR target/53042 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 01fea6f930c..5fb09467069 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3322,7 +3322,18 @@ cp_build_function_call_vec (tree function, VEC(tree,gc) **params, || TREE_CODE (function) == TEMPLATE_ID_EXPR)) { if (complain & tf_error) - error ("%qE cannot be used as a function", original); + { + if (!flag_diagnostics_show_caret) + error_at (input_location, + "%qE cannot be used as a function", original); + else if (DECL_P (original)) + error_at (input_location, + "%qD cannot be used as a function", original); + else + error_at (input_location, + "expression cannot be used as a function"); + } + return error_mark_node; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d0ceb140a21..f5ac6345892 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-04-21 Manuel López-Ibáñez + + PR 35441 + * c-c++-common/pr35441.C: New. + 2012-04-20 Ian Lance Taylor * go.test/go-test.exp (go-set-goarch): Recognize powerpc*-*-*.