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] Fix PR10371 (Regression in main trunk)


Hi

The following patch fixes an incorrect processing in
finish_non_static_data_member.  A COMPONENT_REF is built instead of
the correct SCOPE_REF.   So the information about qualifying scope is
lost.  For example, in the testcase provided in the patch, the
information about the scope of 'A::i' is lost so GCC think that the
referred 'i' is a member of 'B<...>' rather than 'A' during template
argument substitution.  This is a regression in the main trunk.

Tested on i686-pc-linux-gnu.  OK to commit to the trunk?

--Kriang


2003-04-27  Kriang Lerdsuwanakij  <lerdsuwa at users dot sourceforge dot net>

	PR c++/10371
	* semantics.c (finish_non_static_data_member): Build a SCOPE_REF
	when qualifying scope is present.

2003-04-27  Kriang Lerdsuwanakij  <lerdsuwa at users dot sourceforge dot net>

	PR c++/10371
	* g++.dg/lookup/scoped6.C: New test.


diff -cprN gcc-main-save/gcc/cp/semantics.c gcc-main-new/gcc/cp/semantics.c
*** gcc-main-save/gcc/cp/semantics.c	Sun Apr 27 19:25:53 2003
--- gcc-main-new/gcc/cp/semantics.c	Sun Apr 27 17:07:27 2003
*************** finish_non_static_data_member (tree decl
*** 1206,1213 ****
      }
    TREE_USED (current_class_ptr) = 1;
    if (processing_template_decl)
!     return build_min (COMPONENT_REF, TREE_TYPE (decl),
! 		      current_class_ref, DECL_NAME (decl));
    else
      {
        tree access_type = current_class_type;
--- 1206,1218 ----
      }
    TREE_USED (current_class_ptr) = 1;
    if (processing_template_decl)
!     {
!       if (!qualifying_scope)
! 	return build_min (COMPONENT_REF, TREE_TYPE (decl),
! 			  current_class_ref, DECL_NAME (decl));
!       else
! 	return build_min_nt (SCOPE_REF, qualifying_scope, DECL_NAME (decl));
!     }
    else
      {
        tree access_type = current_class_type;
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/lookup/scoped6.C gcc-main-new/gcc/testsuite/g++.dg/lookup/scoped6.C
*** gcc-main-save/gcc/testsuite/g++.dg/lookup/scoped6.C	Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/lookup/scoped6.C	Sun Apr 27 19:28:17 2003
***************
*** 0 ****
--- 1,18 ----
+ // { dg-do compile }
+ 
+ // Origin: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
+ 
+ // PR c++/10371: Incorrect tree node built in
+ // finish_non_static_data_member.
+ 
+ struct A
+ {
+     int i;
+ };
+ 
+ template <int> struct B
+ {
+     int foo() { return A::i; }	// { dg-error "not a base type" }
+ };
+ 
+ void bar() { B<0>().foo(); }	// { dg-error "instantiated" }


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