re PR c/35441 (pretty-printer cannot handle some expressions)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Sat, 21 Apr 2012 14:53:21 +0000 (14:53 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Sat, 21 Apr 2012 14:53:21 +0000 (14:53 +0000)
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

gcc/ChangeLog
gcc/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog

index 0d5457d6501f1cb506255b59e1bd6c32c3d0b036..94e92477e464c8efef969c3546a341facf2ce2b4 100644 (file)
@@ -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
index e7060e2c3d28ca808327ec0194df527e76a969fc..2cd9572ec61a64380ad048c47bc84127fd088a1e 100644 (file)
@@ -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;
     }
 
index e9af16c9f0a70451ebcc77c63302e1e007dd70d2..479ff69416eb705bd1d269942355c9f1586dcd47 100644 (file)
@@ -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
index 01fea6f930c837aa5110ff108c8634a4ac8c8b5f..5fb0946706932d0e1719c48eed8736e025433e8a 100644 (file)
@@ -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;
     }
 
index d0ceb140a2129ace64eb3b50fb7fed2850a8d4f2..f5ac6345892a534d47dfc0c91f13c878d9b8daf5 100644 (file)
@@ -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*-*-*.