This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch,committed] Fix PR c++/26036: ICE on function call with wrong number of arguments


The gimplifier chokes on the trees produced by the C++ frontend
for the following (invalid) testcase:

  struct A
  {
      int i;
  };

  A foo(int);

  int j = foo().i;

Since GCC 4.0 we get the following error message:

  PR26036.cc:6: error: too few arguments to function 'A foo(int)'
  PR26036.cc:8: error: at this point in file
  PR26036.cc: In function 'void __static_initialization_and_destruction_0(int, int)':
  PR26036.cc:8: internal compiler error: in gimple_add_tmp_var, at gimplify.c:532

The ICE can be fixed by returning error_mark_node instead of error_mark_list
in convert_arguments in typeck.c. This declares the whole function call to
foo as invalid instead of just the conversion of zero arguments into one
argument.

This has the additional bonus that error_mark_list can be removed as it
is then unused.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Committed to mainline, 4.1 branch, and 4.0 branch as preapproved by Mark:
http://gcc.gnu.org/ml/gcc-bugs/2006-04/msg01558.html

Regards,
Volker

:ADDPATCH C++:


2006-04-19  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/26036
	* typeck.c (convert_arguments): Return error_mark_node instead of
	error_mark_list.
	* cp-tree.h (error_mark_list): Remove declaration.
	* decl.c (error_mark_list): Remove definition.
	(cxx_init_decl_processing): Do not initialize error_mark_list.

===================================================================
--- gcc/gcc/cp/typeck.c	2006-04-18 17:32:06 +0200
+++ gcc/gcc/cp/typeck.c	2006-04-18 17:32:31 +0200
@@ -2788,7 +2788,7 @@ convert_arguments (tree typelist, tree v
 	    }
 	  else
 	    error ("too few arguments to function");
-	  return error_mark_list;
+	  return error_mark_node;
 	}
     }
 
===================================================================
--- gcc/gcc/cp/cp-tree.h	2006-03-21 04:19:06 +0100
+++ gcc/gcc/cp/cp-tree.h	2006-04-18 20:34:33 +0200
@@ -3184,10 +3184,6 @@ typedef enum base_kind {
 			     binfo.  */
 } base_kind;
 
-/* in decl{2}.c */
-/* A node that is a list (length 1) of error_mark_nodes.  */
-extern GTY(()) tree error_mark_list;
-
 /* Node for "pointer to (virtual) function".
    This may be distinct from ptr_type_node so gdb can distinguish them.  */
 #define vfunc_ptr_type_node  vtable_entry_type
===================================================================
--- gcc/gcc/cp/decl.c	2006-04-18 20:36:12 +0200
+++ gcc/gcc/cp/decl.c	2006-04-18 20:36:38 +0200
@@ -106,9 +106,6 @@ static void initialize_local_var (tree, 
 static void expand_static_init (tree, tree);
 static tree next_initializable_field (tree);
 
-/* Erroneous argument lists can use this *IFF* they do not modify it.  */
-tree error_mark_list;
-
 /* The following symbols are subsumed in the cp_global_trees array, and
    listed here individually for documentation purposes.
 
@@ -3118,9 +3115,6 @@ cxx_init_decl_processing (void)
   /* Initially, C.  */
   current_lang_name = lang_name_c;
 
-  error_mark_list = build_tree_list (error_mark_node, error_mark_node);
-  TREE_TYPE (error_mark_list) = error_mark_node;
-
   /* Create the `std' namespace.  */
   push_namespace (std_identifier);
   std_node = current_namespace;
===================================================================

2006-04-19  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/26036
	* g++.dg/expr/call3.C: New test.

===================================================================
--- gcc/gcc/testsuite/g++.dg/expr/call3.C	2003-09-23 19:59:22 +0200
+++ gcc/gcc/testsuite/g++.dg/expr/call3.C	2006-04-18 21:02:22 +0200
@@ -0,0 +1,12 @@
+// PR c++/26036
+// Origin: <ben@pc-doctor.com>
+// { dg-do compile }
+
+struct A
+{
+  int i;
+};
+
+A foo(int);       // { dg-error "too few arguments" }
+
+int j = foo().i;  // { dg-error "at this point" }
===================================================================



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]