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,committed] Fix PR12924 (TEMPLATE_ID_EXPR handling infinish_class_member_access_expr)


Hi

This obvious patch fix the ICE PR12924 which is a regression in GCC 3.4.
We simply forget to deal with TEMPLATE_ID_EXPR that has OVERLOAD,
TEMPLATE_DECL, as its first operand besides IDENTIFIER_NODE.
Committed to trunk.  Tested on i686-pc-linux-gnu.

--Kriang

2003-11-23  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/12924
	* typeck.c (finish_class_member_access_expr): Handle TEMPLATE_ID_EXPR
	with OVERLOAD and DECL nodes as the first operand.

2003-11-23  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/12924
	* g++.dg/template/template-id-2.C: New test.


diff -cprN gcc-main-save/gcc/cp/typeck.c gcc-main-new/gcc/cp/typeck.c
*** gcc-main-save/gcc/cp/typeck.c	Sun Nov 16 15:01:41 2003
--- gcc-main-new/gcc/cp/typeck.c	Sat Nov 22 21:33:26 2003
*************** finish_class_member_access_expr (tree ob
*** 1860,1865 ****
--- 1860,1870 ----
  	  is_template_id = true;
  	  template_args = TREE_OPERAND (name, 1);
  	  name = TREE_OPERAND (name, 0);
+ 
+ 	  if (TREE_CODE (name) == OVERLOAD)
+ 	    name = DECL_NAME (get_first_fn (name));
+ 	  else if (DECL_P (name))
+ 	    name = DECL_NAME (name);
  	}
  
        if (TREE_CODE (name) == SCOPE_REF)
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/template/template-id-2.C gcc-main-new/gcc/testsuite/g++.dg/template/template-id-2.C
*** gcc-main-save/gcc/testsuite/g++.dg/template/template-id-2.C	Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/template/template-id-2.C	Sun Nov 23 18:08:45 2003
***************
*** 0 ****
--- 1,22 ----
+ // { dg-do compile }
+ 
+ // Origin: Richard Guenther <rguenth@tat.physik.uni-tuebingen.de>
+ 
+ // PR c++/12924
+ 
+ template<typename> struct A {};
+ 
+ template<> struct A<void>
+ {
+     template<typename T> void foo()
+     {
+         A<T> a;
+         a.template foo<int>();	// { dg-error "no member" }
+     }
+ };
+ 
+ void bar()
+ {
+     A<void> a;
+     a.foo<int>();		// { dg-error "instantiated" }
+ }


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