+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
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) \
/* 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))
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. */
+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.
--- /dev/null
+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 {}