aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2003-01-16 20:30:50 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-01-16 20:30:50 +0000
commit8fbc5ae72379506e4344297591db49fceac3a799 (patch)
treea9333721985e67177f1e06a4c7ccc9166503d5bd /gcc
parent07488f322a10f0f8cc56385e3ab01b4c6b1f5a41 (diff)
downloadgcc-8fbc5ae72379506e4344297591db49fceac3a799.zip
gcc-8fbc5ae72379506e4344297591db49fceac3a799.tar.gz
gcc-8fbc5ae72379506e4344297591db49fceac3a799.tar.bz2
cp-tree.h (lang_type_class): Remove is_partial_instantiation.
* cp-tree.h (lang_type_class): Remove is_partial_instantiation. (PARTIAL_INSTANTIATION_P): Remove. (IMPLICIT_TYPENAME_P): Likewise. (IMPLICIT_TYPENAME_TYPE_DECL_P): Likewise. (build_typename_type): Remove declaration. (parmlist_is_exprlist): Likewise. * decl.c (build_typename_type): Make it static, remove third parameter. (push_class_binding): Don't do implicit typename stuff. (make_typename_type): Likewise. (lookup_name_real): Likewise. (grokdeclarator): Don't try to convert declarations into initializations. Don't do implicit typename stuff. (parmlist_is_exprlist): Remove. (xref_basetypes): Simplify. * decl2.c (grokfield): Don't try to convert declarations into initializations. (build_anon_union_vars): Do this while processing templates, too. (finish_anon_union): Likewise. * error.c (dump_type): Remove implicit typename handling. * parser.c (cp_parser_diagnose_invalid_type_name): New method. (cp_parser_primary_expression): Correct handling of names not found by unqualified name lookup in templates. (cp_parser_nested_name_specifier_opt): Avoid checking dependency of types when possible. (cp_parser_simple_declaration): Complain intelligently about some invalid declarations. (cp_parser_member_declaration): Likewise. (cp_parser_constructor_declarator_p): Don't check when we're in a function scope. * pt.c (instantiate_class_template): Remove PARTIAL_INSTANTIATION_P gunk. * search.c (lookup_field_r): Don't build implicit typenames. (marked_pushdecls_p): Don't enter dependent base types. (unmarked_pushdecls_p): Likewise. * semantics.c (begin_class_definition): Remove implicit typename stuff. * config/locale/gnu/messages_members.h: Use this-> to refer to unqualified members of base clasess. * config/locale/ieee_1003.1-2001/codecvt_specializations.h: Likewise. * include/bits/codecvt.h: Likewise. * include/bits/deque.tcc: Likewise. * include/bits/fstream.tcc: Likewise. * include/bits/istream.tcc: Likewise. * include/bits/list.tcc: Likewise. * include/bits/locale_facets.h: Likewise. * include/bits/ostream.tcc: Likewise. * include/bits/sstream.tcc: Likewise. * include/bits/stl_bvector.h: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_tree.h: Likewise. * include/bits/stl_vector.h: Likewise. * include/bits/vector.tcc: Likewise. * include/ext/ropeimpl.h: Likewise. * include/ext/stdio_filebuf.h: Likewise. * include/ext/stl_rope.h: Likewise. * include/std/std_fstream.h: Likewise. * include/std/std_sstream.h: Likewise. Co-Authored-By: Jeffrey Oldham <oldham@codesourcery.com> From-SVN: r61403
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog40
-rw-r--r--gcc/cp/cp-tree.h26
-rw-r--r--gcc/cp/decl.c307
-rw-r--r--gcc/cp/decl2.c51
-rw-r--r--gcc/cp/error.c3
-rw-r--r--gcc/cp/parser.c126
-rw-r--r--gcc/cp/pt.c81
-rw-r--r--gcc/cp/search.c8
-rw-r--r--gcc/cp/semantics.c54
-rw-r--r--gcc/testsuite/ChangeLog30
-rw-r--r--gcc/testsuite/g++.dg/ext/typename1.C2
-rw-r--r--gcc/testsuite/g++.dg/parse/typename2.C17
-rw-r--r--gcc/testsuite/g++.dg/template/crash1.C4
-rw-r--r--gcc/testsuite/g++.dg/template/crash2.C2
-rw-r--r--gcc/testsuite/g++.dg/template/typename2.C4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C6
-rw-r--r--gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.brendan/crash56.C6
-rw-r--r--gcc/testsuite/g++.old-deja/g++.law/visibility13.C4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.ns/template17.C12
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/crash3.C4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/crash36.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/crash5.C6
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/crash67.C4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/inherit1.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/typename16.C4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/typename19.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.robertl/eb112.C3
-rw-r--r--gcc/testsuite/g++.old-deja/g++.robertl/eb24.C2
31 files changed, 371 insertions, 447 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 39b294d..aea2a4c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,43 @@
+2003-01-16 Mark Mitchell <mark@codesourcery.com>
+
+ * cp-tree.h (lang_type_class): Remove is_partial_instantiation.
+ (PARTIAL_INSTANTIATION_P): Remove.
+ (IMPLICIT_TYPENAME_P): Likewise.
+ (IMPLICIT_TYPENAME_TYPE_DECL_P): Likewise.
+ (build_typename_type): Remove declaration.
+ (parmlist_is_exprlist): Likewise.
+ * decl.c (build_typename_type): Make it static, remove third
+ parameter.
+ (push_class_binding): Don't do implicit typename stuff.
+ (make_typename_type): Likewise.
+ (lookup_name_real): Likewise.
+ (grokdeclarator): Don't try to convert declarations into
+ initializations. Don't do implicit typename stuff.
+ (parmlist_is_exprlist): Remove.
+ (xref_basetypes): Simplify.
+ * decl2.c (grokfield): Don't try to convert declarations into
+ initializations.
+ (build_anon_union_vars): Do this while processing templates, too.
+ (finish_anon_union): Likewise.
+ * error.c (dump_type): Remove implicit typename handling.
+ * parser.c (cp_parser_diagnose_invalid_type_name): New method.
+ (cp_parser_primary_expression): Correct handling of names not
+ found by unqualified name lookup in templates.
+ (cp_parser_nested_name_specifier_opt): Avoid checking dependency
+ of types when possible.
+ (cp_parser_simple_declaration): Complain intelligently about some
+ invalid declarations.
+ (cp_parser_member_declaration): Likewise.
+ (cp_parser_constructor_declarator_p): Don't check when we're in a
+ function scope.
+ * pt.c (instantiate_class_template): Remove
+ PARTIAL_INSTANTIATION_P gunk.
+ * search.c (lookup_field_r): Don't build implicit typenames.
+ (marked_pushdecls_p): Don't enter dependent base types.
+ (unmarked_pushdecls_p): Likewise.
+ * semantics.c (begin_class_definition): Remove implicit typename
+ stuff.
+
2003-01-16 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9212
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 612fd56..90c2e59 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1133,6 +1133,7 @@ struct lang_type_class GTY(())
unsigned has_arrow_overloaded : 1;
unsigned interface_only : 1;
unsigned interface_unknown : 1;
+ unsigned contains_empty_class_p : 1;
unsigned marks: 6;
unsigned vec_new_uses_cookie : 1;
@@ -1152,13 +1153,11 @@ struct lang_type_class GTY(())
unsigned has_complex_assign_ref : 1;
unsigned has_abstract_assign_ref : 1;
unsigned non_aggregate : 1;
- unsigned is_partial_instantiation : 1;
unsigned java_interface : 1;
-
unsigned anon_aggr : 1;
+
unsigned non_zero_init : 1;
unsigned empty_p : 1;
- unsigned contains_empty_class_p : 1;
/* When adding a flag here, consider whether or not it ought to
apply to a template instance if it applies to the template. If
@@ -1167,7 +1166,7 @@ struct lang_type_class GTY(())
/* There are some bits left to fill out a 32-bit word. Keep track
of this by updating the size of this bitfield whenever you add or
remove a flag. */
- unsigned dummy : 5;
+ unsigned dummy : 6;
tree primary_base;
tree vfields;
@@ -2412,17 +2411,6 @@ struct lang_decl GTY(())
TEMPLATE_ID_EXPR if we had something like `typename X::Y<T>'. */
#define TYPENAME_TYPE_FULLNAME(NODE) (TYPE_FIELDS (NODE))
-/* Nonzero if NODE is an implicit typename. */
-#define IMPLICIT_TYPENAME_P(NODE) \
- (TREE_CODE (NODE) == TYPENAME_TYPE && TREE_TYPE (NODE))
-
-/* Nonzero if NODE is a TYPE_DECL that should not be visible because
- it is from a dependent base class. */
-#define IMPLICIT_TYPENAME_TYPE_DECL_P(NODE) \
- (TREE_CODE (NODE) == TYPE_DECL \
- && DECL_ARTIFICIAL (NODE) \
- && IMPLICIT_TYPENAME_P (TREE_TYPE (NODE)))
-
/* Nonzero in INTEGER_CST means that this int is negative by dint of
using a twos-complement negated operand. */
#define TREE_NEGATED_INT(NODE) TREE_LANG_FLAG_0 (INTEGER_CST_CHECK (NODE))
@@ -2908,12 +2896,6 @@ struct lang_decl GTY(())
#define DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION(DECL) \
(DECL_TEMPLATE_INFO (DECL) && !DECL_USE_TEMPLATE (DECL))
-/* Nonzero if TYPE is a partial instantiation of a template class,
- i.e., an instantiation whose instantiation arguments involve
- template types. */
-#define PARTIAL_INSTANTIATION_P(TYPE) \
- (LANG_TYPE_CLASS_CHECK (TYPE)->is_partial_instantiation)
-
/* Nonzero iff we are currently processing a declaration for an
entity with its own template parameter list, and which is not a
full specialization. */
@@ -3765,7 +3747,6 @@ extern tree binding_for_name (tree, tree);
extern tree namespace_binding (tree, tree);
extern void set_namespace_binding (tree, tree, tree);
extern tree lookup_namespace_name (tree, tree);
-extern tree build_typename_type (tree, tree, tree, tree);
extern tree make_typename_type (tree, tree, tsubst_flags_t);
extern tree make_unbound_class_template (tree, tree, tsubst_flags_t);
extern tree lookup_name_nonclass (tree);
@@ -3800,7 +3781,6 @@ extern int complete_array_type (tree, tree, int);
extern tree build_ptrmemfunc_type (tree);
extern tree build_ptrmem_type (tree, tree);
/* the grokdeclarator prototype is in decl.h */
-extern int parmlist_is_exprlist (tree);
extern int copy_fn_p (tree);
extern tree get_scope_of_declarator (tree);
extern void grok_special_member_properties (tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 42bbdc8..4f3d9ed 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -147,6 +147,7 @@ static void initialize_local_var (tree, tree);
static void expand_static_init (tree, tree);
static tree next_initializable_field (tree);
static tree reshape_init (tree, tree *);
+static tree build_typename_type (tree, tree, tree);
#if defined (DEBUG_BINDING_LEVELS)
static void indent (void);
@@ -1093,27 +1094,18 @@ push_class_binding (tree id, tree decl)
binding = IDENTIFIER_BINDING (id);
if (BINDING_VALUE (binding) == decl && TREE_CODE (decl) != TREE_LIST)
{
- /* Any implicit typename must be from a base-class. The
- context for an implicit typename declaration is always
- the derived class in which the lookup was done, so the checks
- based on the context of DECL below will not trigger. */
- if (IMPLICIT_TYPENAME_TYPE_DECL_P (decl))
- INHERITED_VALUE_BINDING_P (binding) = 1;
+ if (TREE_CODE (decl) == OVERLOAD)
+ context = CP_DECL_CONTEXT (OVL_CURRENT (decl));
else
{
- if (TREE_CODE (decl) == OVERLOAD)
- context = CP_DECL_CONTEXT (OVL_CURRENT (decl));
- else
- {
- my_friendly_assert (DECL_P (decl), 0);
- context = context_for_name_lookup (decl);
- }
-
- if (is_properly_derived_from (current_class_type, context))
- INHERITED_VALUE_BINDING_P (binding) = 1;
- else
- INHERITED_VALUE_BINDING_P (binding) = 0;
+ my_friendly_assert (DECL_P (decl), 0);
+ context = context_for_name_lookup (decl);
}
+
+ if (is_properly_derived_from (current_class_type, context))
+ INHERITED_VALUE_BINDING_P (binding) = 1;
+ else
+ INHERITED_VALUE_BINDING_P (binding) = 0;
}
else if (BINDING_VALUE (binding) == decl)
/* We only encounter a TREE_LIST when push_class_decls detects an
@@ -5437,7 +5429,7 @@ typename_compare (const void * k1, const void * k2)
static GTY ((param_is (union tree_node))) htab_t typename_htab;
tree
-build_typename_type (tree context, tree name, tree fullname, tree base_type)
+build_typename_type (tree context, tree name, tree fullname)
{
tree t;
tree d;
@@ -5453,7 +5445,6 @@ build_typename_type (tree context, tree name, tree fullname, tree base_type)
t = make_aggr_type (TYPENAME_TYPE);
TYPE_CONTEXT (t) = FROB_CONTEXT (context);
TYPENAME_TYPE_FULLNAME (t) = fullname;
- TREE_TYPE (t) = base_type;
/* Build the corresponding TYPE_DECL. */
d = build_decl (TYPE_DECL, name, t);
@@ -5586,16 +5577,6 @@ make_typename_type (tree context, tree name, tsubst_flags_t complain)
if (DECL_ARTIFICIAL (t) || !(complain & tf_keep_type_decl))
t = TREE_TYPE (t);
- if (IMPLICIT_TYPENAME_P (t))
- {
- /* Lookup found an implicit typename that we had
- injected into the current scope. Doing things
- properly would have located the exact same type,
- so there is no error here. We must remove the
- implicitness so that we do not warn about it. */
- t = copy_node (t);
- TREE_TYPE (t) = NULL_TREE;
- }
return t;
}
@@ -5611,7 +5592,7 @@ make_typename_type (tree context, tree name, tsubst_flags_t complain)
return error_mark_node;
}
- return build_typename_type (context, name, fullname, NULL_TREE);
+ return build_typename_type (context, name, fullname);
}
/* Resolve `CONTEXT::template NAME'. Returns an appropriate type,
@@ -5935,7 +5916,6 @@ lookup_name_real (tree name,
{
tree t;
tree val = NULL_TREE;
- int val_is_implicit_typename = 0;
/* Conversion operators are handled specially because ordinary
unqualified name lookup will not find template conversion
@@ -5990,29 +5970,19 @@ lookup_name_real (tree name,
else
binding = NULL_TREE;
- if (binding
- && (!val || !IMPLICIT_TYPENAME_TYPE_DECL_P (binding)))
+ if (binding)
{
- if (val_is_implicit_typename)
- warn_about_implicit_typename_lookup (val, binding);
val = binding;
- val_is_implicit_typename
- = IMPLICIT_TYPENAME_TYPE_DECL_P (val);
- if (!val_is_implicit_typename)
- break;
+ break;
}
}
/* Now lookup in namespace scopes. */
- if (!val || val_is_implicit_typename)
+ if (!val)
{
t = unqualified_namespace_lookup (name, flags, 0);
if (t)
- {
- if (val_is_implicit_typename)
- warn_about_implicit_typename_lookup (val, t);
- val = t;
- }
+ val = t;
}
if (val)
@@ -9723,9 +9693,6 @@ grokdeclarator (tree declarator,
/* See the code below that used this. */
tree decl_attr = NULL_TREE;
#endif
- /* Set this to error_mark_node for FIELD_DECLs we could not handle properly.
- All FIELD_DECLs we build here have `init' put into their DECL_INITIAL. */
- tree init = NULL_TREE;
/* Keep track of what sort of function is being processed
so that we can warn about default return values, or explicit
@@ -9825,46 +9792,6 @@ grokdeclarator (tree declarator,
break;
case CALL_EXPR:
- if (parmlist_is_exprlist (CALL_DECLARATOR_PARMS (decl)))
- {
- /* This is actually a variable declaration using
- constructor syntax. We need to call start_decl and
- cp_finish_decl so we can get the variable
- initialized... */
-
- tree attributes;
-
- if (decl_context != NORMAL)
- {
- error ("variable declaration is not allowed here");
- return error_mark_node;
- }
-
- *next = TREE_OPERAND (decl, 0);
- init = CALL_DECLARATOR_PARMS (decl);
-
- if (attrlist)
- {
- attributes = *attrlist;
- }
- else
- {
- attributes = NULL_TREE;
- }
-
- decl = start_decl (declarator, declspecs, 1,
- attributes, NULL_TREE);
- if (decl)
- {
- /* Look for __unused__ attribute */
- if (TREE_USED (TREE_TYPE (decl)))
- TREE_USED (decl) = 1;
- finish_decl (decl, init, NULL_TREE);
- }
- else
- error ("invalid declarator");
- return NULL_TREE;
- }
innermost_code = TREE_CODE (decl);
if (decl_context == FIELD && ctype == NULL_TREE)
ctype = current_class_type;
@@ -10294,21 +10221,6 @@ grokdeclarator (tree declarator,
type = integer_type_node;
}
- if (type && IMPLICIT_TYPENAME_P (type))
- {
- /* The implicit typename extension is deprecated and will be
- removed. Warn about its use now. */
- warning ("`%T' is implicitly a typename", type);
- cp_deprecated ("implicit typename");
-
- /* Now remove its implicitness, so that we don't warn again.
- For instance this might be a typedef, and we do not want to
- warn on uses of the typedef itself. Simply clearing the
- TREE_TYPE is insufficient. */
- type = copy_node (type);
- TREE_TYPE (type) = NULL_TREE;
- }
-
ctype = NULL_TREE;
/* Now process the modifiers that were specified
@@ -11903,32 +11815,6 @@ grokdeclarator (tree declarator,
}
}
-/* Tell if a parmlist/exprlist looks like an exprlist or a parmlist.
- An empty exprlist is a parmlist. An exprlist which
- contains only identifiers at the global level
- is a parmlist. Otherwise, it is an exprlist. */
-
-int
-parmlist_is_exprlist (tree exprs)
-{
- if (exprs == NULL_TREE || TREE_PARMLIST (exprs))
- return 0;
-
- if (toplevel_bindings_p ())
- {
- /* At the global level, if these are all identifiers,
- then it is a parmlist. */
- while (exprs)
- {
- if (TREE_CODE (TREE_VALUE (exprs)) != IDENTIFIER_NODE)
- return 1;
- exprs = TREE_CHAIN (exprs);
- }
- return 0;
- }
- return 1;
-}
-
/* Subroutine of start_function. Ensure that each of the parameter
types (as listed in PARMS) is complete, as is required for a
function definition. */
@@ -12963,9 +12849,9 @@ xref_basetypes (tree ref, tree binfo)
/* In the declaration `A : X, Y, ... Z' we mark all the types
(A, X, Y, ..., Z) so we can check for duplicates. */
tree binfos;
- tree base;
+ tree *basep;
- int i, len;
+ int i;
enum tag_types tag_code;
if (TREE_CODE (ref) == UNION_TYPE)
@@ -12976,17 +12862,25 @@ xref_basetypes (tree ref, tree binfo)
tag_code = (CLASSTYPE_DECLARED_CLASS (ref) ? class_type : record_type);
- len = list_length (binfo);
-
/* First, make sure that any templates in base-classes are
instantiated. This ensures that if we call ourselves recursively
we do not get confused about which classes are marked and which
are not. */
- for (base = binfo; base; base = TREE_CHAIN (base))
- complete_type (TREE_VALUE (base));
+ basep = &binfo;
+ while (*basep)
+ {
+ tree basetype = TREE_VALUE (*basep);
+ if (!(processing_template_decl && uses_template_parms (basetype))
+ && !complete_type_or_else (basetype, NULL))
+ /* An incomplete type. Remove it form the list. */
+ *basep = TREE_CHAIN (*basep);
+ else
+ basep = &TREE_CHAIN (*basep);
+ }
SET_CLASSTYPE_MARKED (ref);
- BINFO_BASETYPES (TYPE_BINFO (ref)) = binfos = make_tree_vec (len);
+ BINFO_BASETYPES (TYPE_BINFO (ref)) = binfos
+ = make_tree_vec (list_length (binfo));
for (i = 0; binfo; binfo = TREE_CHAIN (binfo))
{
@@ -13021,85 +12915,74 @@ xref_basetypes (tree ref, tree binfo)
continue;
}
- /* This code replaces similar code in layout_basetypes.
- We put the complete_type first for implicit `typename'. */
- if (!COMPLETE_TYPE_P (basetype)
- && ! (current_template_parms && uses_template_parms (basetype)))
+ if (CLASSTYPE_MARKED (basetype))
{
- error ("base class `%T' has incomplete type", basetype);
+ if (basetype == ref)
+ error ("recursive type `%T' undefined", basetype);
+ else
+ error ("duplicate base type `%T' invalid", basetype);
continue;
}
- else
- {
- if (CLASSTYPE_MARKED (basetype))
- {
- if (basetype == ref)
- error ("recursive type `%T' undefined", basetype);
- else
- error ("duplicate base type `%T' invalid", basetype);
- continue;
- }
-
- if (TYPE_FOR_JAVA (basetype)
- && (current_lang_depth () == 0))
- TYPE_FOR_JAVA (ref) = 1;
-
- /* Note that the BINFO records which describe individual
- inheritances are *not* shared in the lattice! They
- cannot be shared because a given baseclass may be
- inherited with different `accessibility' by different
- derived classes. (Each BINFO record describing an
- individual inheritance contains flags which say what
- the `accessibility' of that particular inheritance is.) */
-
- base_binfo
- = make_binfo (size_zero_node, basetype,
- CLASS_TYPE_P (basetype)
- ? TYPE_BINFO_VTABLE (basetype) : NULL_TREE,
- CLASS_TYPE_P (basetype)
- ? TYPE_BINFO_VIRTUALS (basetype) : NULL_TREE);
-
- TREE_VEC_ELT (binfos, i) = base_binfo;
- TREE_VIA_PUBLIC (base_binfo) = via_public;
- TREE_VIA_PROTECTED (base_binfo) = via_protected;
- TREE_VIA_VIRTUAL (base_binfo) = via_virtual;
- BINFO_INHERITANCE_CHAIN (base_binfo) = TYPE_BINFO (ref);
-
- /* We need to unshare the binfos now so that lookups during class
- definition work. */
- unshare_base_binfos (base_binfo);
-
- SET_CLASSTYPE_MARKED (basetype);
-
- /* We are free to modify these bits because they are meaningless
- at top level, and BASETYPE is a top-level type. */
- if (via_virtual || TYPE_USES_VIRTUAL_BASECLASSES (basetype))
- {
- TYPE_USES_VIRTUAL_BASECLASSES (ref) = 1;
- /* Converting to a virtual base class requires looking
- up the offset of the virtual base. */
- TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref) = 1;
- }
- if (CLASS_TYPE_P (basetype))
- {
- TYPE_HAS_NEW_OPERATOR (ref)
- |= TYPE_HAS_NEW_OPERATOR (basetype);
- TYPE_HAS_ARRAY_NEW_OPERATOR (ref)
- |= TYPE_HAS_ARRAY_NEW_OPERATOR (basetype);
- TYPE_GETS_DELETE (ref) |= TYPE_GETS_DELETE (basetype);
- /* If the base-class uses multiple inheritance, so do we. */
- TYPE_USES_MULTIPLE_INHERITANCE (ref)
- |= TYPE_USES_MULTIPLE_INHERITANCE (basetype);
- /* Likewise, if converting to a base of the base may require
- code, then we may need to generate code to convert to a
- base as well. */
- TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref)
- |= TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (basetype);
- }
-
- i += 1;
- }
+ if (TYPE_FOR_JAVA (basetype)
+ && (current_lang_depth () == 0))
+ TYPE_FOR_JAVA (ref) = 1;
+
+ /* Note that the BINFO records which describe individual
+ inheritances are *not* shared in the lattice! They
+ cannot be shared because a given baseclass may be
+ inherited with different `accessibility' by different
+ derived classes. (Each BINFO record describing an
+ individual inheritance contains flags which say what
+ the `accessibility' of that particular inheritance is.) */
+
+ base_binfo
+ = make_binfo (size_zero_node, basetype,
+ CLASS_TYPE_P (basetype)
+ ? TYPE_BINFO_VTABLE (basetype) : NULL_TREE,
+ CLASS_TYPE_P (basetype)
+ ? TYPE_BINFO_VIRTUALS (basetype) : NULL_TREE);
+
+ TREE_VEC_ELT (binfos, i) = base_binfo;
+ TREE_VIA_PUBLIC (base_binfo) = via_public;
+ TREE_VIA_PROTECTED (base_binfo) = via_protected;
+ TREE_VIA_VIRTUAL (base_binfo) = via_virtual;
+ BINFO_INHERITANCE_CHAIN (base_binfo) = TYPE_BINFO (ref);
+
+ /* We need to unshare the binfos now so that lookups during class
+ definition work. */
+ unshare_base_binfos (base_binfo);
+
+ SET_CLASSTYPE_MARKED (basetype);
+
+ /* We are free to modify these bits because they are meaningless
+ at top level, and BASETYPE is a top-level type. */
+ if (via_virtual || TYPE_USES_VIRTUAL_BASECLASSES (basetype))
+ {
+ TYPE_USES_VIRTUAL_BASECLASSES (ref) = 1;
+ /* Converting to a virtual base class requires looking
+ up the offset of the virtual base. */
+ TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref) = 1;
+ }
+
+ if (CLASS_TYPE_P (basetype))
+ {
+ TYPE_HAS_NEW_OPERATOR (ref)
+ |= TYPE_HAS_NEW_OPERATOR (basetype);
+ TYPE_HAS_ARRAY_NEW_OPERATOR (ref)
+ |= TYPE_HAS_ARRAY_NEW_OPERATOR (basetype);
+ TYPE_GETS_DELETE (ref) |= TYPE_GETS_DELETE (basetype);
+ /* If the base-class uses multiple inheritance, so do we. */
+ TYPE_USES_MULTIPLE_INHERITANCE (ref)
+ |= TYPE_USES_MULTIPLE_INHERITANCE (basetype);
+ /* Likewise, if converting to a base of the base may require
+ code, then we may need to generate code to convert to a
+ base as well. */
+ TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref)
+ |= TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (basetype);
+ }
+
+ i += 1;
}
if (i)
TREE_VEC_LENGTH (binfos) = i;
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 6179df6..4401dcc 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -846,35 +846,6 @@ grokfield (tree declarator, tree declspecs, tree init, tree asmspec_tree,
const char *asmspec = 0;
int flags = LOOKUP_ONLYCONVERTING;
- /* Convert () initializers to = initializers. */
- if (init == NULL_TREE && declarator != NULL_TREE
- && TREE_CODE (declarator) == CALL_EXPR
- && TREE_OPERAND (declarator, 0)
- && (TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE
- || TREE_CODE (TREE_OPERAND (declarator, 0)) == SCOPE_REF)
- && parmlist_is_exprlist (CALL_DECLARATOR_PARMS (declarator)))
- {
- /* It's invalid to try to initialize a data member using a
- functional notation, e.g.:
-
- struct S {
- static int i (3);
- };
-
- Explain that to the user. */
- static int explained;
-
- error ("invalid data member initialization");
- if (!explained)
- {
- error ("(use `=' to initialize static data members)");
- explained = 1;
- }
-
- declarator = TREE_OPERAND (declarator, 0);
- flags = 0;
- }
-
if (declspecs == NULL_TREE
&& TREE_CODE (declarator) == SCOPE_REF
&& TREE_CODE (TREE_OPERAND (declarator, 1)) == IDENTIFIER_NODE)
@@ -1280,8 +1251,11 @@ build_anon_union_vars (tree object)
else if (TREE_PROTECTED (field))
cp_pedwarn_at ("protected member `%#D' in anonymous union", field);
- ref = build_class_member_access_expr (object, field, NULL_TREE,
- false);
+ if (processing_template_decl)
+ ref = build_min_nt (COMPONENT_REF, object, DECL_NAME (field));
+ else
+ ref = build_class_member_access_expr (object, field, NULL_TREE,
+ false);
if (DECL_NAME (field))
{
@@ -1327,16 +1301,15 @@ finish_anon_union (tree anon_union_decl)
return;
}
- if (!processing_template_decl)
+ main_decl = build_anon_union_vars (anon_union_decl);
+ if (main_decl == NULL_TREE)
{
- main_decl = build_anon_union_vars (anon_union_decl);
-
- if (main_decl == NULL_TREE)
- {
- warning ("anonymous union with no members");
- return;
- }
+ warning ("anonymous union with no members");
+ return;
+ }
+ if (!processing_template_decl)
+ {
/* Use main_decl to set the mangled name. */
DECL_NAME (anon_union_decl) = DECL_NAME (main_decl);
mangle_decl (anon_union_decl);
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 37a7f67..d9bc552 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -454,8 +454,7 @@ dump_type (t, flags)
break;
}
case TYPENAME_TYPE:
- if (!IMPLICIT_TYPENAME_P (t))
- output_add_string (scratch_buffer, "typename ");
+ output_add_string (scratch_buffer, "typename ");
dump_typename (t, flags);
break;
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 07b35a2..75d7a64 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -1758,6 +1758,8 @@ static bool cp_parser_simulate_error
PARAMS ((cp_parser *));
static void cp_parser_check_type_definition
PARAMS ((cp_parser *));
+static bool cp_parser_diagnose_invalid_type_name
+ (cp_parser *);
static bool cp_parser_skip_to_closing_parenthesis
PARAMS ((cp_parser *));
static bool cp_parser_skip_to_closing_parenthesis_or_comma
@@ -2201,6 +2203,83 @@ cp_parser_check_type_definition (parser)
error ("%s", parser->type_definition_forbidden_message);
}
+/* Check for a common situation where a type-name should be present,
+ but is not, and issue a sensible error message. Returns true if an
+ invalid type-name was detected. */
+
+static bool
+cp_parser_diagnose_invalid_type_name (cp_parser *parser)
+{
+ /* If the next two tokens are both identifiers, the code is
+ erroneous. The usual cause of this situation is code like:
+
+ T t;
+
+ where "T" should name a type -- but does not. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)
+ && cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_NAME)
+ {
+ tree name;
+
+ /* If parsing tenatively, we should commit; we really are
+ looking at a declaration. */
+ /* Consume the first identifier. */
+ name = cp_lexer_consume_token (parser->lexer)->value;
+ /* Issue an error message. */
+ error ("`%s' does not name a type", IDENTIFIER_POINTER (name));
+ /* If we're in a template class, it's possible that the user was
+ referring to a type from a base class. For example:
+
+ template <typename T> struct A { typedef T X; };
+ template <typename T> struct B : public A<T> { X x; };
+
+ The user should have said "typename A<T>::X". */
+ if (processing_template_decl && current_class_type)
+ {
+ tree b;
+
+ for (b = TREE_CHAIN (TYPE_BINFO (current_class_type));
+ b;
+ b = TREE_CHAIN (b))
+ {
+ tree base_type = BINFO_TYPE (b);
+ if (CLASS_TYPE_P (base_type)
+ && cp_parser_dependent_type_p (base_type))
+ {
+ tree field;
+ /* 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 = (TREE_TYPE
+ (DECL_TEMPLATE_RESULT
+ (DECL_PRIMARY_TEMPLATE
+ (CLASSTYPE_TI_TEMPLATE (base_type)))));
+ for (field = TYPE_FIELDS (base_type);
+ field;
+ field = TREE_CHAIN (field))
+ if (TREE_CODE (field) == TYPE_DECL
+ && DECL_NAME (field) == name)
+ {
+ error ("(perhaps `typename %T::%s' was intended)",
+ BINFO_TYPE (b), IDENTIFIER_POINTER (name));
+ break;
+ }
+ if (field)
+ break;
+ }
+ }
+ }
+ /* Skip to the end of the declaration; there's no point in
+ trying to process it. */
+ cp_parser_skip_to_end_of_statement (parser);
+
+ return true;
+ }
+
+ return false;
+}
+
/* Consume tokens up to, and including, the next non-nested closing `)'.
Returns TRUE iff we found a closing `)'. */
@@ -2744,15 +2823,21 @@ cp_parser_primary_expression (cp_parser *parser,
}
}
- /* If unqualified name lookup fails while processing a
- template, that just means that we need to do name
- lookup again when the template is instantiated. */
if (!parser->scope
&& decl == error_mark_node
&& processing_template_decl)
{
+ /* Unqualified name lookup failed while processing a
+ template. */
*idk = CP_PARSER_ID_KIND_UNQUALIFIED;
- return build_min_nt (LOOKUP_EXPR, id_expression);
+ /* If the next token is a parenthesis, assume that
+ Koenig lookup will succeed when instantiating the
+ template. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN))
+ return build_min_nt (LOOKUP_EXPR, id_expression);
+ /* If we're not doing Koenig lookup, issue an error. */
+ error ("`%D' has not been declared", id_expression);
+ return error_mark_node;
}
else if (decl == error_mark_node
&& !processing_template_decl)
@@ -3521,7 +3606,12 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
: new_scope);
/* If it is a class scope, try to complete it; we are about to
be looking up names inside the class. */
- if (TYPE_P (parser->scope))
+ if (TYPE_P (parser->scope)
+ /* Since checking types for dependency can be expensive,
+ avoid doing it if the type is already complete. */
+ && !COMPLETE_TYPE_P (parser->scope)
+ /* Do not try to complete dependent types. */
+ && !cp_parser_dependent_type_p (parser->scope))
complete_type (parser->scope);
}
@@ -6656,6 +6746,21 @@ cp_parser_simple_declaration (parser, function_definition_allowed_p)
/* We no longer need to defer access checks. */
stop_deferring_access_checks ();
+ /* If the next two tokens are both identifiers, the code is
+ erroneous. The usual cause of this situation is code like:
+
+ T t;
+
+ where "T" should name a type -- but does not. */
+ if (cp_parser_diagnose_invalid_type_name (parser))
+ {
+ /* If parsing tenatively, we should commit; we really are
+ looking at a declaration. */
+ cp_parser_commit_to_tentative_parse (parser);
+ /* Give up. */
+ return;
+ }
+
/* Keep going until we hit the `;' at the end of the simple
declaration. */
saw_declarator = false;
@@ -12061,6 +12166,9 @@ cp_parser_member_declaration (parser)
CP_PARSER_FLAGS_OPTIONAL,
&prefix_attributes,
&declares_class_or_enum);
+ /* Check for an invalid type-name. */
+ if (cp_parser_diagnose_invalid_type_name (parser))
+ return;
/* If there is no declarator, then the decl-specifier-seq should
specify a type. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
@@ -13818,7 +13926,11 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p)
cp_token *next_token;
/* The common case is that this is not a constructor declarator, so
- try to avoid doing lots of work if at all possible. */
+ try to avoid doing lots of work if at all possible. It's not
+ valid declare a constructor at function scope. */
+ if (at_function_scope_p ())
+ return false;
+ /* And only certain tokens can begin a constructor declarator. */
next_token = cp_lexer_peek_token (parser->lexer);
if (next_token->type != CPP_NAME
&& next_token->type != CPP_SCOPE
@@ -13853,7 +13965,7 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p)
{
/* If we have:
- template <typename T> struct S { S(); }
+ template <typename T> struct S { S(); };
template <typename T> S<T>::S ();
we must recognize that the nested `S' names a class.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 133318d..91cf89c 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5152,63 +5152,26 @@ instantiate_class_template (type)
/* Figure out which arguments are being used to do the
instantiation. */
args = CLASSTYPE_TI_ARGS (type);
- PARTIAL_INSTANTIATION_P (type) = uses_template_parms (args);
-
- if (pedantic && PARTIAL_INSTANTIATION_P (type))
- /* If this is a partial instantiation, then we can't instantiate
- the type; there's no telling whether or not one of the
- template parameters might eventually be instantiated to some
- value that results in a specialization being used. For
- example, consider:
-
- template <class T>
- struct S {};
-
- template <class U>
- void f(S<U>);
-
- template <>
- struct S<int> {};
-
- Now, the `S<U>' in `f<int>' is the specialization, not an
- instantiation of the original template. */
- return type;
/* Determine what specialization of the original template to
instantiate. */
- if (PARTIAL_INSTANTIATION_P (type))
- /* There's no telling which specialization is appropriate at this
- point. Since all peeking at the innards of this partial
- instantiation are extensions (like the "implicit typename"
- extension, which allows users to omit the keyword `typename' on
- names that are declared as types in template base classes), we
- are free to do what we please.
-
- Trying to figure out which partial instantiation to use can
- cause a crash. (Some of the template arguments don't even have
- types.) So, we just use the most general version. */
- t = NULL_TREE;
- else
+ t = most_specialized_class (template, args);
+ if (t == error_mark_node)
{
- t = most_specialized_class (template, args);
-
- if (t == error_mark_node)
+ const char *str = "candidates are:";
+ error ("ambiguous class template instantiation for `%#T'", type);
+ for (t = DECL_TEMPLATE_SPECIALIZATIONS (template); t;
+ t = TREE_CHAIN (t))
{
- const char *str = "candidates are:";
- error ("ambiguous class template instantiation for `%#T'", type);
- for (t = DECL_TEMPLATE_SPECIALIZATIONS (template); t;
- t = TREE_CHAIN (t))
+ if (get_class_bindings (TREE_VALUE (t), TREE_PURPOSE (t),
+ args))
{
- if (get_class_bindings (TREE_VALUE (t), TREE_PURPOSE (t),
- args))
- {
- cp_error_at ("%s %+#T", str, TREE_TYPE (t));
- str = " ";
- }
+ cp_error_at ("%s %+#T", str, TREE_TYPE (t));
+ str = " ";
}
- TYPE_BEING_DEFINED (type) = 1;
- return error_mark_node;
}
+ TYPE_BEING_DEFINED (type) = 1;
+ return error_mark_node;
}
if (t)
@@ -5221,26 +5184,6 @@ instantiate_class_template (type)
if (!COMPLETE_TYPE_P (pattern))
return type;
- /* If this is a partial instantiation, don't tsubst anything. We will
- only use this type for implicit typename, so the actual contents don't
- matter. All that matters is whether a particular name is a type. */
- if (PARTIAL_INSTANTIATION_P (type))
- {
- /* The fields set here must be kept in sync with those cleared
- in begin_class_definition. */
- TYPE_BINFO_BASETYPES (type) = TYPE_BINFO_BASETYPES (pattern);
- TYPE_FIELDS (type) = TYPE_FIELDS (pattern);
- TYPE_METHODS (type) = TYPE_METHODS (pattern);
- CLASSTYPE_DECL_LIST (type) = CLASSTYPE_DECL_LIST (pattern);
- CLASSTYPE_TAGS (type) = CLASSTYPE_TAGS (pattern);
- CLASSTYPE_VBASECLASSES (type) = CLASSTYPE_VBASECLASSES (pattern);
-
- /* Pretend that the type is complete, so that we will look
- inside it during name lookup and such. */
- TYPE_SIZE (type) = bitsize_zero_node;
- return type;
- }
-
/* If we've recursively instantiated too many templates, stop. */
if (! push_tinst_level (type))
return type;
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 0895a76..29ee667 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -1350,7 +1350,7 @@ lookup_field_r (binfo, data)
}
else
{
- if (from_dep_base_p && TREE_CODE (nval) != TYPE_DECL
+ if (from_dep_base_p && TREE_CODE (nval) == TYPE_DECL
/* We need to return a member template class so we can
define partial specializations. Is there a better
way? */
@@ -1500,9 +1500,7 @@ lookup_member (xbasetype, name, protect, want_type)
/* If the thing we found was found via the implicit typename
extension, build the typename type. */
if (rval && lfi.from_dep_base_p && !DECL_CLASS_TEMPLATE_P (rval))
- rval = TYPE_STUB_DECL (build_typename_type (BINFO_TYPE (basetype_path),
- name, name,
- TREE_TYPE (rval)));
+ abort ();
if (rval && is_overloaded_fn (rval))
rval = build_baselink (rval_binfo, basetype_path, rval,
@@ -2187,6 +2185,7 @@ marked_pushdecls_p (binfo, data)
void *data ATTRIBUTE_UNUSED;
{
return (CLASS_TYPE_P (BINFO_TYPE (binfo))
+ && !dependent_base_p (binfo)
&& BINFO_PUSHDECLS_MARKED (binfo)) ? binfo : NULL_TREE;
}
@@ -2196,6 +2195,7 @@ unmarked_pushdecls_p (binfo, data)
void *data ATTRIBUTE_UNUSED;
{
return (CLASS_TYPE_P (BINFO_TYPE (binfo))
+ && !dependent_base_p (binfo)
&& !BINFO_PUSHDECLS_MARKED (binfo)) ? binfo : NULL_TREE;
}
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index e3ae9be..adba8a5 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1797,11 +1797,6 @@ begin_class_definition (t)
error ("definition of `%#T' inside template parameter list", t);
return error_mark_node;
}
-
- /* In a definition of a member class template, we will get here with
- an implicit typename. */
- if (IMPLICIT_TYPENAME_P (t))
- t = TREE_TYPE (t);
/* A non-implicit typename comes from code like:
template <typename T> struct A {
@@ -1820,56 +1815,9 @@ begin_class_definition (t)
pushtag (make_anon_name (), t, 0);
}
- /* If we generated a partial instantiation of this type, but now
- we're seeing a real definition, we're actually looking at a
- partial specialization. Consider:
-
- template <class T, class U>
- struct Y {};
-
- template <class T>
- struct X {};
-
- template <class T, class U>
- void f()
- {
- typename X<Y<T, U> >::A a;
- }
-
- template <class T, class U>
- struct X<Y<T, U> >
- {
- };
-
- We have to undo the effects of the previous partial
- instantiation. */
- if (PARTIAL_INSTANTIATION_P (t))
- {
- if (!pedantic)
- {
- /* Unfortunately, when we're not in pedantic mode, we
- attempt to actually fill in some of the fields of the
- partial instantiation, in order to support the implicit
- typename extension. Clear those fields now, in
- preparation for the definition here. The fields cleared
- here must match those set in instantiate_class_template.
- Look for a comment mentioning begin_class_definition
- there. */
- TYPE_BINFO_BASETYPES (t) = NULL_TREE;
- TYPE_FIELDS (t) = NULL_TREE;
- TYPE_METHODS (t) = NULL_TREE;
- CLASSTYPE_DECL_LIST (t) = NULL_TREE;
- CLASSTYPE_TAGS (t) = NULL_TREE;
- CLASSTYPE_VBASECLASSES (t) = NULL_TREE;
- TYPE_SIZE (t) = NULL_TREE;
- }
-
- /* This isn't a partial instantiation any more. */
- PARTIAL_INSTANTIATION_P (t) = 0;
- }
/* If this type was already complete, and we see another definition,
that's an error. */
- else if (COMPLETE_TYPE_P (t))
+ if (COMPLETE_TYPE_P (t))
duplicate_tag_error (t);
/* Update the location of the decl. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f40783f..55e4028 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,33 @@
+2003-01-16 Mark Mitchell <mark@codesourcery.com>
+
+ * gcc/testsuite/g++.dg/ext/typename1.C: Add typename keyword.
+ * gcc/testsuite/g++.dg/template/crash1.C: Update error messages.
+ * gcc/testsuite/g++.dg/template/crash2.C: Remove error message.
+ * gcc/testsuite/g++.dg/parse/typename2.C: New test.
+ * gcc/testsuite/g++.dg/template/typename2.C: Change implicit
+ typename warning into error.
+ * gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C: Issue more
+ error messages.
+ * gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C: Fix typos.
+ * gcc/testsuite/g++.old-deja/g++.brendan/crash56.C: Add this->.
+ * gcc/testsuite/g++.old-deja/g++.law/visibility13.C: Remove error
+ messages.
+ * gcc/testsuite/g++.old-deja/g++.ns/template17.C: Reorder code to
+ make declaration visible in template.
+ * gcc/testsuite/g++.old-deja/g++.pt/crash3.C: Fix typos.
+ * gcc/testsuite/g++.old-deja/g++.pt/crash36.C: Issue more error
+ messages.
+ * gcc/testsuite/g++.old-deja/g++.pt/crash5.C: Improve error
+ message.
+ * gcc/testsuite/g++.old-deja/g++.pt/crash67.C: Remove warning.
+ * gcc/testsuite/g++.old-deja/g++.pt/inherit1.C: Add this->.
+ * gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C: Add error message.
+ * gcc/testsuite/g++.old-deja/g++.pt/typename16.C: Replace implicit
+ typename warning with error message.
+ * gcc/testsuite/g++.old-deja/g++.pt/typename19.C: Remove warning.
+ * gcc/testsuite/g++.old-deja/g++.robertl/eb112.C: Fix typo.
+ * gcc/testsuite/g++.old-deja/g++.robertl/eb24.C: Use this->.
+
2003-01-16 Nathan Sidwell <nathan@codesourcery.com>
* g++.dg/parse/ambig2.C: New test.
diff --git a/gcc/testsuite/g++.dg/ext/typename1.C b/gcc/testsuite/g++.dg/ext/typename1.C
index f66210f..cb9f4a7 100644
--- a/gcc/testsuite/g++.dg/ext/typename1.C
+++ b/gcc/testsuite/g++.dg/ext/typename1.C
@@ -3,5 +3,5 @@
template <class T> struct A { typedef int X; };
template <class T> struct B { typedef A<T> Y; void f (typename Y::X); };
-template <class T, class T1, class T2, class T3> struct C : public B<T> { void g (typename Y::X); };
+template <class T, class T1, class T2, class T3> struct C : public B<T> { void g (typename B<T>::Y::X); };
template class B<int>;
diff --git a/gcc/testsuite/g++.dg/parse/typename2.C b/gcc/testsuite/g++.dg/parse/typename2.C
new file mode 100644
index 0000000..8878497
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/typename2.C
@@ -0,0 +1,17 @@
+template<class T, class U>
+struct UnaryReturn {
+ typedef T Type_t;
+};
+
+struct foo
+{
+ template <class T>
+ typename UnaryReturn<T, int>::Type_t
+ bar();
+};
+
+template<class T>
+struct UnaryReturn<T, int> {
+ typedef bool Type_t;
+};
+
diff --git a/gcc/testsuite/g++.dg/template/crash1.C b/gcc/testsuite/g++.dg/template/crash1.C
index 3879ad5..16d584e 100644
--- a/gcc/testsuite/g++.dg/template/crash1.C
+++ b/gcc/testsuite/g++.dg/template/crash1.C
@@ -1,6 +1,6 @@
// { dg-do compile }
-// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 29 Dec 2001 <nathan@codesourcery.com>
// PR 5125. ICE
@@ -12,6 +12,6 @@ class S
};
template <class I>
-void S::Foo(int (*f)(TYPO&o) ) // { dg-error "Foo" }
+void S::Foo(int (*f)(TYPO&o) ) // { dg-error "Foo|f|TYPO|o" }
{ // { dg-error "expected `;'" }
}
diff --git a/gcc/testsuite/g++.dg/template/crash2.C b/gcc/testsuite/g++.dg/template/crash2.C
index e6cc965..a02787a 100644
--- a/gcc/testsuite/g++.dg/template/crash2.C
+++ b/gcc/testsuite/g++.dg/template/crash2.C
@@ -17,7 +17,7 @@ enum E { max = 5 };
struct B
{
- A<E> a; // { dg-error "" }
+ A<E> a;
};
}
diff --git a/gcc/testsuite/g++.dg/template/typename2.C b/gcc/testsuite/g++.dg/template/typename2.C
index 0ca1163..644c62a 100644
--- a/gcc/testsuite/g++.dg/template/typename2.C
+++ b/gcc/testsuite/g++.dg/template/typename2.C
@@ -1,7 +1,7 @@
// { dg-do compile }
// { dg-options "" }
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 21 Mar 2002 <nathan@codesourcery.com>
// PR 5507. Overzealous implicit typename warning
@@ -21,5 +21,5 @@ class ctype : public __ctype_abstract_base<_CharT>
template<typename _CharT>
class ctype2 : public __ctype_abstract_base<_CharT>
{
- typedef mask mask; // { dg-warning "(implicitly a typename)|(implicit typename)" "" }
+ typedef mask mask; // { dg-error "" }
};
diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C
index 1dae2a9..80490e9 100644
--- a/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C
+++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C
@@ -127,7 +127,7 @@ public:
friend bool foo(T161 u)
{
Xseven<T161, 5, int> obj; // ERROR - .*
- return (obj.inst == u.inst);
+ return (obj.inst == u.inst); // ERROR - .*
}
};
@@ -192,10 +192,10 @@ template <long l>// ERROR - .*
struct Xthirteen {
template <long l> long comp_ge(long test) {// ERROR - .
long local_value;
- if (local_value > value)
+ if (local_value > value) // ERROR - .*
return local_value;
else
- return value;
+ return value; // ERROR - .*
}
};
diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C
index 0330d0b..3c01be7 100644
--- a/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C
+++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C
@@ -115,7 +115,7 @@ protected:
template <class T17, int i> struct Xtwenty {
void f(){
T17 my_type; //ok
- for (int j = 0; j < 5; ++l)
+ for (int j = 0; j < 5; ++j)
{
T17 my_type; //ok
++my_type;
diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C
index fc6af32..0523f1f 100644
--- a/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C
+++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C
@@ -51,7 +51,7 @@ unsigned short X_one<T>::ret_id() {
export template <class T2> // WARNING -
bool compare_ge(T2 test) {
- if (test > type)
+ if (test > type) // ERROR - .*
return true;
return false;
}
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C
index 739dfcb..78c291b 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C
@@ -273,10 +273,10 @@ template<class T>
void
SetLD<T>::remove(const T& item)
{
- typename ListD<T>::Action a = NORMAL;
+ typename ListD<T>::Action a = this->NORMAL;
Vix x;
- for (first(x); 0 != x && REMOVE_CURRENT != a; next(x, a))
- a = operator()(x) == item ? REMOVE_CURRENT: NORMAL;// ERROR - .*
+ for (first(x); 0 != x && this->REMOVE_CURRENT != a; next(x, a))
+ a = operator()(x) == item ? this->REMOVE_CURRENT: this->NORMAL; // ERROR - .*
}
template<class T>
bool
diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility13.C b/gcc/testsuite/g++.old-deja/g++.law/visibility13.C
index 472d5a2..2a74151 100644
--- a/gcc/testsuite/g++.old-deja/g++.law/visibility13.C
+++ b/gcc/testsuite/g++.old-deja/g++.law/visibility13.C
@@ -25,8 +25,8 @@ public:
virtual Type& operator[](int ix) { return ia[ix]; }
private:
void init(const Type*, int);
- int size; // ERROR - private
- int *ia; // ERROR - private
+ int size;
+ int *ia;
};
template <class Type>
diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template17.C b/gcc/testsuite/g++.old-deja/g++.ns/template17.C
index 11f21c9..a441ebe 100644
--- a/gcc/testsuite/g++.old-deja/g++.ns/template17.C
+++ b/gcc/testsuite/g++.old-deja/g++.ns/template17.C
@@ -1,6 +1,6 @@
// Build don't link:
//
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 29 Apr 2001 <nathan@codesourcery.com>
// Bug 2258. We failed to implement using directives inside template
@@ -16,6 +16,11 @@ namespace whatever
template <typename T> void fn (T, T (*)(T));
+namespace whatever
+{
+ template <typename T> T end3 (T);
+}
+
template <class T> void mycout(const T& data)
{
using namespace thing;
@@ -25,11 +30,6 @@ template <class T> void mycout(const T& data)
fn (data, end3);
}
-namespace whatever
-{
- template <typename T> T end3 (T);
-}
-
int main()
{
double data = 5.0;
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash3.C b/gcc/testsuite/g++.old-deja/g++.pt/crash3.C
index 0d2a7cd..a6133e1 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/crash3.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/crash3.C
@@ -5,12 +5,12 @@ class CVector {
public:
CVector<int> f() const
{
- CVector<int> v(n);
+ CVector<int> v();
return v;
}
CVector<long> g() const
{
- CVector<long> v(n);
+ CVector<long> v();
return v;
}
};
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash36.C b/gcc/testsuite/g++.old-deja/g++.pt/crash36.C
index f9cbed2..938591f 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/crash36.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/crash36.C
@@ -29,7 +29,7 @@ struct list {
reverse_iterator<list_iterator<T> > rbegin()
{ return reverse_iterator<list_iterator<T> > // ERROR - no type|instantiated here
- (list_iterator<T>(Head->next())); }
+ (list_iterator<T>(Head->next())); } // ERROR - not declared
};
template class list<int>;
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash5.C b/gcc/testsuite/g++.old-deja/g++.pt/crash5.C
index 99a7791..c36f5d7 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/crash5.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/crash5.C
@@ -1,12 +1,12 @@
// Build don't link:
template <class T, int i>
-struct K { // ERROR - forward declaration
+struct K {
void f();
};
template <class T>
void
-K<T, i>::f()
-{ // ERROR - template parameters
+K<T, i>::f() // ERROR - i has not been declared
+{
}
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash67.C b/gcc/testsuite/g++.old-deja/g++.pt/crash67.C
index b532e3d..646763a 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/crash67.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/crash67.C
@@ -1,7 +1,7 @@
// Build don't link:
// Special g++ Options:
//
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 6 May 2001 <nathan@codesourcery.com>
// Bug 2526. We ICE'd after diagnosing dependent name confusion in
@@ -16,5 +16,5 @@ struct B
template<typename T>
struct D : B<T>
{
- friend class Mother; // WARNING - defines namespace class
+ friend class Mother;
};
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C b/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C
index 6ae70c1..3fb5656 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C
@@ -14,7 +14,7 @@ template <int dim>
class FinalClass : public Derived<dim> {
public:
FinalClass () {
- if (&local1 != &local2)
+ if (&this->local1 != &this->local2)
i = 0;
}
};
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C b/gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C
index 027f2ae..131964b 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C
@@ -1,6 +1,6 @@
// Build don't link:
-struct A {
+struct A { // ERROR - forward declaration
friend struct B : A { // ERROR -
int x;
};
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename16.C b/gcc/testsuite/g++.old-deja/g++.pt/typename16.C
index 225cc89..f40a6a2 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/typename16.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/typename16.C
@@ -11,7 +11,7 @@ struct D1 : public B {
template <class T>
struct D2 : public D1<T> {
- I i; // WARNING - implicit typename
+ I i; // ERROR - not a type
};
template <>
@@ -27,5 +27,5 @@ void f(double) {}
int main()
{
D2<int> d2i;
- f(d2i.i);
+ f(d2i.i); // ERROR - no member i
}
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename19.C b/gcc/testsuite/g++.old-deja/g++.pt/typename19.C
index be93a98..332f294 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/typename19.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/typename19.C
@@ -12,7 +12,7 @@ struct S {
template <class U>
struct I : public O<U> {
- static X x; // WARNING - lookup finds S<T>::X
+ static X x;
};
};
diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C
index 3233287..c0231b7 100644
--- a/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C
+++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C
@@ -4,8 +4,7 @@ setback(MEMBER *bp, MEMBER STRUCT::*offset)
{
// The implementation of this function may be platform dependend
if(!bp) return 0; // NULL pointers remain NULL
- union { int i; MEMBER STRUCT::*of; } u; // Switch types. Casting won't
-+work.
+ union { int i; MEMBER STRUCT::*of; } u; // Switch types. Casting won't work.
u.of = offset;
return (STRUCT *) ((int) bp - u.i);
}
diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C
index 7ea7b41..528af4c 100644
--- a/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C
+++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C
@@ -19,5 +19,5 @@ class Y : public X<T>
using X<T>::x;
- void f () { std::cout << x << std::endl; }
+ void f () { std::cout << this->x << std::endl; }
};