diff options
author | Mark Mitchell <mark@codesourcery.com> | 2003-02-24 21:52:00 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-02-24 21:52:00 +0000 |
commit | 353b4fc0d72bbbf8a7b975d4d1e9cc6e036f458a (patch) | |
tree | aea7c328c45ca231ae6c3de7a76a3787a6f4bbc4 /gcc | |
parent | 2afced11918b76955f3262608cb4c5f66350fcdc (diff) | |
download | gcc-353b4fc0d72bbbf8a7b975d4d1e9cc6e036f458a.zip gcc-353b4fc0d72bbbf8a7b975d4d1e9cc6e036f458a.tar.gz gcc-353b4fc0d72bbbf8a7b975d4d1e9cc6e036f458a.tar.bz2 |
re PR c++/9836 (Error with typdefs in partial specializations of classes)
PR c++/9836
* cp-tree.h (CLASSTYPE_PRIMARY_TEMPLATE): Do not skip from
specializations back to the main template.
* parser.c (cp_parser_diagnose_invalid_type_name):Adjust use.
* pt.c (resolve_typename_type): Likewise.
PR c++/9836
* g++.dg/template/spec6.C: New test.
From-SVN: r63383
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 10 | ||||
-rw-r--r-- | gcc/cp/parser.c | 3 | ||||
-rw-r--r-- | gcc/cp/pt.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/spec6.C | 10 |
6 files changed, 31 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dff7c4f..e793ab1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2003-02-24 Mark Mitchell <mark@codesourcery.com> + + PR c++/9836 + * cp-tree.h (CLASSTYPE_PRIMARY_TEMPLATE): Do not skip from + specializations back to the main template. + * parser.c (cp_parser_diagnose_invalid_type_name):Adjust use. + * pt.c (resolve_typename_type): Likewise. + 2003-02-24 Jeffrey D. Oldham <oldham@codesourcery.com> PR c++/9778 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 919e529..8e44bbb 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2317,10 +2317,12 @@ struct lang_decl GTY(()) TI_ARGS (ENUM_TEMPLATE_INFO (NODE)) /* For a template instantiation TYPE, returns the TYPE corresponding - to the primary template. */ -#define CLASSTYPE_PRIMARY_TEMPLATE_TYPE(TYPE) \ - TREE_TYPE (DECL_TEMPLATE_RESULT (DECL_PRIMARY_TEMPLATE \ - (CLASSTYPE_TI_TEMPLATE ((TYPE))))) + to the primary template. Otherwise returns TYPE itself. */ +#define CLASSTYPE_PRIMARY_TEMPLATE_TYPE(TYPE) \ + ((CLASSTYPE_USE_TEMPLATE ((TYPE)) && !CLASSTYPE_TEMPLATE_SPECIALIZATION ((TYPE))) \ + ? TREE_TYPE (DECL_TEMPLATE_RESULT (DECL_PRIMARY_TEMPLATE \ + (CLASSTYPE_TI_TEMPLATE ((TYPE))))) \ + : (TYPE)) /* Like DECL_TI_TEMPLATE, but for an ENUMERAL_, RECORD_, or UNION_TYPE. */ #define TYPE_TI_TEMPLATE(NODE) \ diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 0688cdc..17b7224 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1953,8 +1953,7 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser) /* Go from a particular instantiation of the template (which will have an empty TYPE_FIELDs), to the main version. */ - if (CLASSTYPE_USE_TEMPLATE (base_type)) - base_type = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (base_type); + base_type = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (base_type); for (field = TYPE_FIELDS (base_type); field; field = TREE_CHAIN (field)) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 053a967..a5425f3 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11530,8 +11530,7 @@ resolve_typename_type (tree type, bool only_current_p) return error_mark_node; /* If SCOPE is a partial instantiation, it will not have a valid TYPE_FIELDS list, so use the original template. */ - if (CLASSTYPE_USE_TEMPLATE (scope)) - scope = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope); + scope = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope); /* Enter the SCOPE so that name lookup will be resolved as if we were in the class definition. In particular, SCOPE will no longer be considered a dependent type. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3f847ef..b88756f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-02-24 Mark Mitchell <mark@codesourcery.com> + + PR c++/9836 + * g++.dg/template/spec6.C: New test. + 2003-02-24 Jeff Law <law@redhat.com> * gcc.c-torture/compile/20030224-1.c: New test for ia32 backend bug. diff --git a/gcc/testsuite/g++.dg/template/spec6.C b/gcc/testsuite/g++.dg/template/spec6.C new file mode 100644 index 0000000..915b833 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec6.C @@ -0,0 +1,10 @@ +template <bool, int> struct X {}; + +template <bool C> struct X<C,1> { + typedef double* type; + type foo () const; +}; + +template <bool C> +typename X<C,1>::type +X<C,1>::foo () const {} |