This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix PR10371 regression (revised)
- From: Kriang Lerdsuwanakij <lerdsuwa at users dot sourceforge dot net>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 15 Sep 2003 21:37:01 +0700 (ICT)
- Subject: [C++ PATCH] Fix PR10371 regression (revised)
- Reply-to: <lerdsuwa at users dot sourceforge dot net>
Hi
The following fix is a revised version of an earlier patch
http://gcc.gnu.org/ml/gcc-patches/2003-04/msg02032.html
that correct a regression in 3.4. The function
'finish_non_static_data_member' doesn't handle the case when
both 'processing_template_decl' is non-zero and 'qualifying_scope'
non-null. That is, COMPONENT_REF is built, discarding information
provided by 'qualifying_scope'. The fix in this version is
revised to behave correctly with respect to two-phase name lookup.
So in the testcase 'scoped7.C' included below, the error is caught
during parsing, rather than during template instantiation.
Tested on i686-pc-linux-gnu. OK to commit to the trunk?
--Kriang
2003-09-15 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/10371
* semantics.c (finish_non_static_data_member): Handle when
both processing_template_decl and qualifying_scope are true.
2003-09-15 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/10371
* g++.dg/lookup/scoped7.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 Aug 31 22:33:59 2003
--- gcc-main-new/gcc/cp/semantics.c Sun Sep 14 21:45:26 2003
*************** finish_non_static_data_member (tree decl
*** 1224,1230 ****
return error_mark_node;
}
TREE_USED (current_class_ptr) = 1;
! if (processing_template_decl)
{
tree type = TREE_TYPE (decl);
--- 1224,1230 ----
return error_mark_node;
}
TREE_USED (current_class_ptr) = 1;
! if (processing_template_decl && !qualifying_scope)
{
tree type = TREE_TYPE (decl);
*************** finish_non_static_data_member (tree decl
*** 1263,1268 ****
--- 1263,1275 ----
}
}
+ /* If PROCESSING_TEMPLATE_DECL is non-zero here, then
+ QUALIFYING_SCOPE is also non-null. Wrap this in a SCOPE_REF
+ for now. */
+ if (processing_template_decl)
+ return build_min (SCOPE_REF, TREE_TYPE (decl),
+ qualifying_scope, DECL_NAME (decl));
+
perform_or_defer_access_check (TYPE_BINFO (access_type), decl);
/* If the data member was named `C::M', convert `*this' to `C'
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/lookup/scoped7.C gcc-main-new/gcc/testsuite/g++.dg/lookup/scoped7.C
*** gcc-main-save/gcc/testsuite/g++.dg/lookup/scoped7.C Thu Jan 1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/lookup/scoped7.C Sun Sep 14 18:51:59 2003
***************
*** 0 ****
--- 1,16 ----
+ // { dg-do compile }
+
+ // Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+ // PR c++/10371: Incorrect tree node built in
+ // finish_non_static_data_member.
+
+ struct A
+ {
+ int i; // { dg-error "object missing" }
+ };
+
+ template <int> struct B
+ {
+ int foo() { return A::i; } // { dg-error "this location" }
+ };