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]

C++ PATCH: PR 14616


This patch fixes PR c++/14616, a regression affecting Boost.

Tested on i686-pc-linux-gnu, applied on the mainline and on the 3.4
branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-03-21  Mark Mitchell  <mark@codesourcery.com>

	PR c++/14616
	* decl.c (cp_finish_decl): Compute the size of arrays declared in
	templates, if their type is non-dependent.

2004-03-21  Mark Mitchell  <mark@codesourcery.com>

	PR c++/14616
	* g++.dg/init/array13.C: New test.

Index: testsuite/g++.dg/init/array13.C
===================================================================
RCS file: testsuite/g++.dg/init/array13.C
diff -N testsuite/g++.dg/init/array13.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/init/array13.C	21 Mar 2004 17:38:30 -0000
***************
*** 0 ****
--- 1,9 ----
+ template <typename DisjointSet> 
+ struct test_disjoint_set { 
+   static void do_test() 
+   { 
+     unsigned int elts[] 
+         = { 0, 1, 2, 3 }; 
+     const int N = sizeof(elts)/sizeof(*elts); 
+   } 
+ }; 
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1174.2.16
diff -c -5 -p -r1.1174.2.16 decl.c
*** cp/decl.c	20 Mar 2004 00:13:08 -0000	1.1174.2.16
--- cp/decl.c	21 Mar 2004 17:38:32 -0000
*************** cp_finish_decl (tree decl, tree init, tr
*** 4775,4784 ****
--- 4775,4788 ----
        if (at_function_scope_p ())
  	add_decl_stmt (decl);
  
        if (init && DECL_INITIAL (decl))
  	DECL_INITIAL (decl) = init;
+       if (TREE_CODE (decl) == VAR_DECL
+ 	  && !DECL_PRETTY_FUNCTION_P (decl)
+ 	  && !dependent_type_p (TREE_TYPE (decl)))
+ 	maybe_deduce_size_from_array_init (decl, init);
        goto finish_end0;
      }
  
    /* Parameters are handled by store_parm_decls, not cp_finish_decl.  */
    my_friendly_assert (TREE_CODE (decl) != PARM_DECL, 19990828);


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