aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2012-04-21 14:53:21 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2012-04-21 14:53:21 +0000
commitae52741c5e69eafabc749445ca991b01857f4ea0 (patch)
treee0172180b9b6ef470102a85cd1da2ee85e3ccdb1 /gcc
parentaab316c7c997b98b4aa4413856c5c743a4bf6f1d (diff)
downloadgcc-ae52741c5e69eafabc749445ca991b01857f4ea0.zip
gcc-ae52741c5e69eafabc749445ca991b01857f4ea0.tar.gz
gcc-ae52741c5e69eafabc749445ca991b01857f4ea0.tar.bz2
re PR c/35441 (pretty-printer cannot handle some expressions)
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. From-SVN: r186652
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/c-typeck.c30
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c13
-rw-r--r--gcc/testsuite/ChangeLog5
5 files changed, 55 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0d5457d..94e9247 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+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
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index e7060e2..2cd9572 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 e9af16c..479ff69 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2012-04-21 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR 35441
+ * typeck.c (cp_build_function_call_vec): Do not pretty-print
+ expressions when caret is enabled.
+
2012-04-20 Jan Hubicka <jh@suse.cz>
PR target/53042
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 01fea6f..5fb0946 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 d0ceb14..f5ac634 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-04-21 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR 35441
+ * c-c++-common/pr35441.C: New.
+
2012-04-20 Ian Lance Taylor <iant@google.com>
* go.test/go-test.exp (go-set-goarch): Recognize powerpc*-*-*.