This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH for 3.3/trunk] Fix PR11513 regression
- From: Kriang Lerdsuwanakij <lerdsuwa at users dot sourceforge dot net>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 20 Jul 2003 18:07:46 +0700 (ICT)
- Subject: [C++ PATCH for 3.3/trunk] Fix PR11513 regression
- Reply-to: <lerdsuwa at users dot sourceforge dot net>
Hi
This patch fixes a 3.3 regression PR11513. In
PROCESSING_REAL_TEMPLATE_DECL_P macro, we are getting correct
results if we are not inside a function scope. Because the macro
checks template level beginning from current_class_type.
If the current scope is a function scope, this scope is ignored.
This is fixed by the patch. It looks straightforward enough
to be considered for 3.3.1.
As for the trunk, another patch of mine:
http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01960.html
also get rid of the bug by not using the above macro in xref_tag.
But the problem in PROCESSING_REAL_TEMPLATE_DECL_P remains and
should be fixed as well
Tested on i686-pc-linux-gnu. OK for 3.3 and trunk?
--Kriang
2003-07-20 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/11513
* cp-tree.h (PROCESSING_REAL_TEMPLATE_DECL_P): Use current_scope.
2003-07-20 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/11513
* g++.dg/template/crash8.C: New test.
diff -cprN gcc-33-save/gcc/cp/cp-tree.h gcc-33-new/gcc/cp/cp-tree.h
*** gcc-33-save/gcc/cp/cp-tree.h Sun Jul 20 16:59:00 2003
--- gcc-33-new/gcc/cp/cp-tree.h Sun Jul 20 16:54:40 2003
*************** struct lang_decl GTY(())
*** 2961,2967 ****
entity with its own template parameter list, and which is not a
full specialization. */
#define PROCESSING_REAL_TEMPLATE_DECL_P() \
! (processing_template_decl > template_class_depth (current_class_type))
/* Nonzero if this VAR_DECL or FUNCTION_DECL has already been
instantiated, i.e. its definition has been generated from the
--- 2961,2967 ----
entity with its own template parameter list, and which is not a
full specialization. */
#define PROCESSING_REAL_TEMPLATE_DECL_P() \
! (processing_template_decl > template_class_depth (current_scope ()))
/* Nonzero if this VAR_DECL or FUNCTION_DECL has already been
instantiated, i.e. its definition has been generated from the
diff -cprN gcc-33-save/gcc/testsuite/g++.dg/template/crash8.C gcc-33-new/gcc/testsuite/g++.dg/template/crash8.C
*** gcc-33-save/gcc/testsuite/g++.dg/template/crash8.C Thu Jan 1 07:00:00 1970
--- gcc-33-new/gcc/testsuite/g++.dg/template/crash8.C Sun Jul 20 16:44:43 2003
***************
*** 0 ****
--- 1,20 ----
+ // { dg-do compile }
+
+ // Origin: David Robinson <drtr@dial.pipex.com>
+
+ // PR c++/11513: ICE due to incorrect decision whether the tag is template.
+
+ template <typename T>
+ struct bar
+ {
+ struct foo
+ {
+ int a;
+ };
+
+ template <typename U>
+ int wom(U c)
+ {
+ struct foo b;
+ }
+ };