[C++ PATCH, committed] Fix PR7982, a regression
Kriang Lerdsuwanakij
lerdsuwa@users.sourceforge.net
Sun Feb 23 14:51:00 GMT 2003
Hi
GCC 3.2/3.3 currently segfault inside warn_about_implicit_typename_lookup
when we want to generate warning about implicit typename in some case.
The code in warn_about_implicit_typename_lookup in one check assume
that the type found by name lookup inside dependent base always has a
lang_specific field, but this is not true for a TYPENAME_TYPE node.
The appended patch adds this check to the function.
Tested on i686-pc-linux-gnu. Commited to 3.3 and 3.2 as obvious.
For main trunk, only the testcase is committed, as the
warn_about_implicit_typename_lookup togetherwith other implicit typename
code are deplicated and removed there.
--Kriang
2003-02-23 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/7982
* decl.c (warn_about_implicit_typename_lookup): Handle TYPEOF_TYPE.
2003-02-23 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/7982
* g++.dg/warn/implicit-typename1.C: New test.
diff -cprN gcc-33-save/gcc/cp/decl.c gcc-33-new/gcc/cp/decl.c
*** gcc-33-save/gcc/cp/decl.c Thu Feb 13 21:20:08 2003
--- gcc-33-new/gcc/cp/decl.c Sat Feb 22 18:27:15 2003
*************** warn_about_implicit_typename_lookup (typ
*** 6034,6039 ****
--- 6034,6040 ----
tree name = DECL_NAME (typename);
if (! (TREE_CODE (binding) == TEMPLATE_DECL
+ && CLASS_TYPE_P (subtype)
&& CLASSTYPE_TEMPLATE_INFO (subtype)
&& CLASSTYPE_TI_TEMPLATE (subtype) == binding)
&& ! (TREE_CODE (binding) == TYPE_DECL
diff -cprN gcc-33-save/gcc/testsuite/g++.dg/warn/implicit-typename1.C gcc-33-new/gcc/testsuite/g++.dg/warn/implicit-typename1.C
*** gcc-33-save/gcc/testsuite/g++.dg/warn/implicit-typename1.C Thu Jan 1 07:00:00 1970
--- gcc-33-new/gcc/testsuite/g++.dg/warn/implicit-typename1.C Sat Feb 22 21:27:35 2003
***************
*** 0 ****
--- 1,17 ----
+ // The -pedantic option must be omitted to trigger the crash.
+ // { dg-do compile }
+ // { dg-options "" }
+
+ // PR c++/7982: Crash warning about implicit typename.
+ // The base class refers to another typename, while the
+ // name lookup finds a template.
+
+ template <typename T> struct X {};
+
+ template <typename T> struct C {
+ typedef typename T::X X;
+ };
+
+ template <typename T> struct A : public C<T> {
+ typedef X<int> X; // { dg-warning "lookup|dependent base|typename" }
+ };
More information about the Gcc-patches
mailing list