diff options
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 93 |
1 files changed, 40 insertions, 53 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 01bc600f2f9..a93241f87ad 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1,6 +1,6 @@ /* Handle parameterized types (templates) for GNU C++. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing. Rewritten by Jason Merrill (jason@cygnus.com). @@ -180,7 +180,9 @@ push_access_scope (tree t) || TREE_CODE (t) == VAR_DECL, 0); - if (DECL_CLASS_SCOPE_P (t)) + if (DECL_FRIEND_CONTEXT (t)) + push_nested_class (DECL_FRIEND_CONTEXT (t)); + else if (DECL_CLASS_SCOPE_P (t)) push_nested_class (DECL_CONTEXT (t)); else push_to_top_level (); @@ -205,7 +207,7 @@ pop_access_scope (tree t) saved_access_scope = TREE_CHAIN (saved_access_scope); } - if (DECL_CLASS_SCOPE_P (t)) + if (DECL_FRIEND_CONTEXT (t) || DECL_CLASS_SCOPE_P (t)) pop_nested_class (); else pop_from_top_level (); @@ -1955,6 +1957,10 @@ check_explicit_specialization (tree declarator, DECL_SOURCE_LOCATION (tmpl) = DECL_SOURCE_LOCATION (decl); DECL_SOURCE_LOCATION (DECL_TEMPLATE_RESULT (tmpl)) = DECL_SOURCE_LOCATION (decl); + /* We want to use the argument list specified in the + definition, not in the original declaration. */ + DECL_ARGUMENTS (DECL_TEMPLATE_RESULT (tmpl)) + = DECL_ARGUMENTS (decl); } return tmpl; } @@ -1991,49 +1997,6 @@ check_explicit_specialization (tree declarator, return decl; } -/* TYPE is being declared. Verify that the use of template headers - and such is reasonable. Issue error messages if not. */ - -void -maybe_check_template_type (tree type) -{ - if (template_header_count) - { - /* We are in the scope of some `template <...>' header. */ - - int context_depth - = template_class_depth_real (TYPE_CONTEXT (type), - /*count_specializations=*/1); - - if (template_header_count <= context_depth) - /* This is OK; the template headers are for the context. We - are actually too lenient here; like - check_explicit_specialization we should consider the number - of template types included in the actual declaration. For - example, - - template <class T> struct S { - template <class U> template <class V> - struct I {}; - }; - - is invalid, but: - - template <class T> struct S { - template <class U> struct I; - }; - - template <class T> template <class U. - struct S<T>::I {}; - - is not. */ - ; - else if (template_header_count > context_depth + 1) - /* There are two many template parameter lists. */ - error ("too many template parameter lists in declaration of `%T'", type); - } -} - /* Returns 1 iff PARMS1 and PARMS2 are identical sets of template parameters. These are represented in the same format used for DECL_TEMPLATE_PARMS. */ @@ -7519,7 +7482,16 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) ctx = tsubst_aggr_type (DECL_CONTEXT (t), args, complain, in_decl, /*entering_scope=*/1); if (ctx != DECL_CONTEXT (t)) - return lookup_field (ctx, DECL_NAME (t), 0, false); + { + tree r = lookup_field (ctx, DECL_NAME (t), 0, false); + if (!r) + { + if (complain & tf_error) + error ("using invalid field `%D'", t); + return error_mark_node; + } + return r; + } } return t; @@ -8454,7 +8426,11 @@ tsubst_copy_and_build (tree t, lookup finds a non-function, in accordance with the expected resolution of DR 218. */ if (koenig_p - && (is_overloaded_fn (function) + && ((is_overloaded_fn (function) + /* If lookup found a member function, the Koenig lookup is + not appropriate, even if an unqualified-name was used + to denote the function. */ + && !DECL_FUNCTION_MEMBER_P (get_first_fn (function))) || TREE_CODE (function) == IDENTIFIER_NODE)) function = perform_koenig_lookup (function, call_args); @@ -8544,7 +8520,9 @@ tsubst_copy_and_build (tree t, else member = tsubst_copy (member, args, complain, in_decl); - if (!CLASS_TYPE_P (TREE_TYPE (object))) + if (member == error_mark_node) + return error_mark_node; + else if (!CLASS_TYPE_P (TREE_TYPE (object))) { if (TREE_CODE (member) == BIT_NOT_EXPR) return finish_pseudo_destructor_expr (object, @@ -8570,9 +8548,14 @@ tsubst_copy_and_build (tree t, /*is_type_p=*/false, /*complain=*/false); if (BASELINK_P (member)) - BASELINK_FUNCTIONS (member) - = build_nt (TEMPLATE_ID_EXPR, BASELINK_FUNCTIONS (member), - args); + { + BASELINK_FUNCTIONS (member) + = build_nt (TEMPLATE_ID_EXPR, BASELINK_FUNCTIONS (member), + args); + member = (adjust_result_of_qualified_name_lookup + (member, BINFO_TYPE (BASELINK_BINFO (member)), + TREE_TYPE (object))); + } else { qualified_name_lookup_error (TREE_TYPE (object), tmpl); @@ -8909,6 +8892,9 @@ fn_type_unification (tree fn, tree converted_args; bool incomplete; + if (explicit_targs == error_mark_node) + return 1; + converted_args = (coerce_template_parms (DECL_INNERMOST_TEMPLATE_PARMS (fn), explicit_targs, NULL_TREE, tf_none, @@ -12243,7 +12229,8 @@ build_non_dependent_expr (tree expr) if (TREE_CODE (inner_expr) == OVERLOAD || TREE_CODE (inner_expr) == FUNCTION_DECL || TREE_CODE (inner_expr) == TEMPLATE_DECL - || TREE_CODE (inner_expr) == TEMPLATE_ID_EXPR) + || TREE_CODE (inner_expr) == TEMPLATE_ID_EXPR + || TREE_CODE (inner_expr) == OFFSET_REF) return expr; /* Preserve string constants; conversions from string constants to "char *" are allowed, even though normally a "const char *" |