+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.
+
2012-04-20 Jim Meyering <meyering@redhat.com>
* genmodes.c (make_complex_modes): Don't truncate a mode name of
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
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;
}
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;
}
{
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;
}
|| 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;
}