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]

Re: C++ PATCH: PR 14724 and PR 14763


Mark Mitchell <mark@codesourcery.com> writes:

| * 14763
| 
|   This was an ICE when certain expressions were used as default
|   arguments in a template class.

Backported to gcc-3_3-branch, with the correction from Jakub.

Bootstrapped and regtest on i686-pc-linux-gnu.

-- Gaby

Index: cp/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/ChangeLog,v
retrieving revision 1.3076.2.266
diff -p -r1.3076.2.266 ChangeLog
*** cp/ChangeLog	1 May 2004 19:57:27 -0000	1.3076.2.266
--- cp/ChangeLog	1 May 2004 20:25:50 -0000
***************
*** 1,5 ****
--- 1,15 ----
  2004-05-01  Gabriel Dos Reis  <gdr@integrable-solutions.net>
  
+ 	Backport from gcc-3_4-branch
+ 	2004-03-30  Mark Mitchell  <mark@codesourcery.com>
+ 	            Jakub Jelinek  <jakub@redhat.com>
+ 	PR c++/14763
+ 	* pt.c (tsubst_default_argument): Clear current_function_decl.
+ 	* decl2.c (mark_used): Don't segfault if cfun != NULL but
+ 	current_function_decl == NULL.
+ 
+ 2004-05-01  Gabriel Dos Reis  <gdr@integrable-solutions.net>
+ 
  	Backport from gcc-3_4-branch:
  	2004-03-30  Mark Mitchell  <mark@codesourcery.com>
  	PR c++/14724
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.575.2.36
diff -p -r1.575.2.36 decl2.c
*** cp/decl2.c	12 Mar 2004 20:53:56 -0000	1.575.2.36
--- cp/decl2.c	1 May 2004 20:25:53 -0000
*************** mark_used (decl)
*** 4879,4884 ****
--- 4879,4885 ----
  		  generate its body to find that out.  */
  	       || TREE_NOTHROW (decl)
  	       || !cfun
+                || !current_function_decl
  	       /* If we already know the current function can't throw,
  		  then we don't need to work hard to prove it.  */
  	       || TREE_NOTHROW (current_function_decl)
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.635.2.44
diff -p -r1.635.2.44 pt.c
*** cp/pt.c	9 Mar 2004 16:23:43 -0000	1.635.2.44
--- cp/pt.c	1 May 2004 20:25:59 -0000
*************** tsubst_default_argument (fn, type, arg)
*** 5905,5910 ****
--- 5905,5914 ----
  
    /* FN is already the desired FUNCTION_DECL.  */
    push_access_scope (fn);
+   /* The default argument expression should not be considered to be
+      within the scope of FN.  Since push_access_scope sets
+      current_function_decl, we must explicitly clear it here.  */
+   current_function_decl = NULL_TREE;
  
    arg = tsubst_expr (arg, DECL_TI_ARGS (fn),
  		     tf_error | tf_warning, NULL_TREE);
Index: testsuite/g++.dg/template/defarg4.C
===================================================================
RCS file: testsuite/g++.dg/template/defarg4.C
diff -N testsuite/g++.dg/template/defarg4.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/defarg4.C	1 May 2004 20:26:00 -0000
***************
*** 0 ****
--- 1,14 ----
+ // PR c++/14763
+ 
+ struct A { 
+   int get() const {} 
+   static A *foo(); 
+ }; 
+  
+ template<bool> struct S { 
+   S(unsigned int = A::foo()->get())  ; 
+ }; 
+  
+ void foo() throw() { 
+   S<false> f; 
+ } 


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