aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
AgeCommit message (Collapse)AuthorFilesLines
2005-02-21re PR c++/19076 (Pointer to member function not matched to pointer to member ↵Douglas Gregor1-16/+43
template) 2005-02-21 Douglas Gregor <dgregor@cs.indiana.edu> PR c++/19076 PR c++/6628 * cp-tree.h (cp_apply_type_quals_to_decl): Declared. * decl.c (grokdeclarator): Pedwarn about qualifying a function type. Add qualifiers when declaring a typedef of a function type. Member function pointers pick up the qualifiers of the typedef used to declare them. Don't complain about creating cv-qualified function types. Complain about qualified function typedefs that are used to declare non-static member functions or free functions. Use cp_apply_type_quals_to_decl. (start_preparsed_function): Use cp_apply_type_quals_to_decl. (grokclassfn): Use cp_apply_type_quals_to_decl. * error.c (dump_type_suffix): Print qualifiers for function types. * pt.c (tsubst_decl): Use cp_apply_type_quals_to_decl. (tsubst): When substituting a function type into a member pointer type, pass along the qualifiers. (unify): Unify member pointers to member function pointers. * tree.c (cp_build_qualified_type_real): Function types may be qualified. This includes restrict qualifiers. * typeck.c (cp_apply_type_quals_to_decl): New function to replace use of c_apply_type_quals_to_decl. Drops qualifiers that are being added to function types. From-SVN: r95356
2005-02-14re PR c++/19884 (ICE on explicit instantiation of a non-template constructor)Nathan Sidwell1-11/+7
cp: PR c++/19884 * pt.c (check_explicit_specialization): Make sure namespace binding lookup found an overloaded function. (lookup_template_function): Just assert FNS is an overloaded function. PR c++/19895 * decl.c (grokdeclarator): Check for error mark node in ptrmem construction. testsuite: PR c++/19895 * g++.dg/parse/ptrmem3.C: New. PR c++/19884 * g++.old-deja/g++.oliva/template6.C: Add another case. * g++.dg/template/explicit6.C: New. From-SVN: r95009
2005-02-12re PR c++/14479 (enum definition in template class with template methods ↵Kriang Lerdsuwanakij1-43/+0
causes error.) PR c++/14479 PR c++/19487 * pt.c (maybe_check_template_type): Remove. * cp-tree.h (maybe_check_template_type): Remove prototype. * name-lookup.c (maybe_process_template_type_declaration): Don't use maybe_check_template_type. * g++.dg/template/enum5.C: New test. From-SVN: r94941
2005-02-11re PR c++/19634 (Infinite memory usage on Alpha)Richard Henderson1-8/+6
PR c++/19632 * pt.c (get_mostly_instantiated_function_type): Save and restore flag_access_control instead of push/pop_access_scope. From-SVN: r94889
2005-02-09re PR c++/19733 (ICE on invalid destructor call)Mark Mitchell1-2/+1
PR c++/19733 * class.c (add_method): Don't set TYPE_HAS_DESTRUCTOR. (check_bases): Give warnings about a base class with a non-virtual destructor, even if it is implicit. (finish_struct_bits): Don't copy TYPE_HAS_DESTRUCTOR. (maybe_warn_about_overly_private_class): Don't use TYPE_HAS_DESTRUCTOR. (finish_struct_methods): Don't set TYPE_HAS_DESTRUCTOR. (check_for_override): Give it external linkage. (add_implicitly_declared_members): Generate destructors lazily. (check_field_decls): Use TYPE_HAS_NONTRIVIAL_DESTRUCTOR, not TYPE_HAS_DESTRUCTOR. (check_bases_and_members): Call check_methods before check_field_decls. (check_bases_and_members): Use TYPE_HAS_NONTRIVIAL_DESTRUCTOR, not TYPE_HAS_DESTRUCTOR. (finish_struct_1): Do not use TYPE_HAS_DESTRUCTOR. * cp-tree.def (PSEUDO_DTOR_EXPR): Document. * cp-tree.h (TYPE_HAS_DESTRUCTOR): Remove. (lang_type_class): Add lazy_destructor. (CLASSTYPE_LAZY_DESTRUCTOR): New macro. (CLASSTYPE_DESTRUCTORS): Robustify. (TYPE_HAS_DESTRUCTOR): Remove. (check_for_override): Declare. (build_vbase_delete): Remove. * cvt.c (convert_to_void): Issue errors about pseudo-destructor expressions. * decl.c (cxx_maybe_build_cleanup): Remove dead code. * except.c (dtor_nothrow): Lazily create destructors if necessary. (build_throw): Use TYPE_HAS_NONTRIVIAL_DESTRUCTOR. * init.c (build_delete): Lazily create destructors, if necessary. (build_vbase_delete): Remove. * method.c (locate_dtor): Simplify. (implicitly_declare_fn): Add support for destructors. * parser.c (cp_parser_lookup_name): Lazily create destructors, if necessary. * pt.c (check_explicit_specialization): Don't use TYPE_HAS_DESTRUCTOR. (instantiate_class_template): Likewise. * ptree.c (cxx_print_type): Don't print TYPE_HAS_DESTRUCTOR. * rtti.c (emit_support_tinfos): Robustify. * search.c (lookup_fnfields_1): Lazily create destructors. * typeck.c (build_class_member_access_expr): Remove PSEUDO_DTOR_EXPR handling. (lookup_destructor): Likewise. PR c++/19733 * g++.dg/parse/crash23.C: New test. * g++.dg/warn/Weff1.C: New test. From-SVN: r94759
2005-02-03re PR c++/19628 (g++ no longer accepts __builtin_constant_p in ↵Matt Austern1-0/+30
constant-expressions) PR c++/19628 * cp-tree.h (builtin_valid_in_constant_expr_p): Declare. * parser.c (cp_parser_postfix_expression): Accept function call in constant expression if builtin_valid_in_constant_expr_p is true for that function. * pt.c (value_dependent_expression_p): Handle CALL_EXPRs properly. * semantics.c (finish_id_expression): Accept function call in constant expression if builtin_valid_in_constant_expr_p is true for that function. * tree.c (builtin_valid_in_constant_expr_p): New. * g++/ext/builtin7.C: New. * g++/ext/builtin8.C: New. From-SVN: r94635
2005-02-02re PR c++/17413 (local classes as template argument)Volker Reichelt1-2/+4
PR c++/17413 * pt.c (check_instantiated_args): Improve error message. Fix logic when to print its second part. PR c++/17413 * g++.dg/template/local4.C: Tweak. From-SVN: r94618
2005-02-01re PR c++/18757 (ICE (on invalid) in get_innermost_template_args)Alexandre Oliva1-0/+3
gcc/cp/ChangeLog: PR c++/18757 PR c++/19366 PR c++/19499 * parser.c (cp_parser_template_id): Revert 2004-12-09's patch. Issue an error when creating the template id. * pt.c (fn_type_unification): Return early if the explicit template arg list is an error_mark_node. gcc/testsuite/ChangeLog: * g++.dg/parse/typename7.C: Adjust error messages. From-SVN: r94520
2005-01-29re PR c++/19667 (ICE on (very trivial) invalid)Mark Mitchell1-0/+7
PR c++/19667 * g++.dg/template/crash32.C: New test. PR c++/19667 * pt.c (redeclare_class_template): Robustify. From-SVN: r94402
2005-01-27tree.h (SWITCH_COND, [...]): Add tree checks.Steven Bosscher1-2/+2
* tree.h (SWITCH_COND, SWITCH_BODY, SWITCH_LABELS, CASE_LOW, CASE_HIGH, CASE_LABEL, ASM_STRING, ASM_OUTPUTS, ASM_INPUTS, ASM_CLOBBERS): Add tree checks. * c-common.h (SWITCH_TYPE): Rename to SWITCH_STMT_TYPE. (SWITCH_STMT_COND, SWITCH_STMT_BODY): New. * c-common.def (SWITCH_STMT): Update to match. * c-common.c (c_do_switch_warnings): Use SWITCH_STMT accessor macros instead of SWITCH_EXPR ones. * c-dump.c (c_dump_tree): Likewise. * c-gimplify.c (gimplify_switch_stmt): Likewise. * c-typeck.c (c_start_case, do_case, c_finish_case): Likewise. cp/ * decl.c (finish_case_label): Use SWITCH_STMT accessor macros instead of SWITCH_EXPR ones. * pt.c (tsubst_expr): Likewise. * semantics.c (begin_switch_stmt, finish_switch_cond, finish_switch_stmt): Likewise. doc/ * c-tree.texi (SWITCH_STMT): Update accessor macro names. From-SVN: r94315
2005-01-21re PR c++/19208 (Spurious error about variably modified type)Giovanni Bajo1-6/+5
PR c++/19208 * pt.c (fold_decl_constant_value): Always call fold_non_dependent_expr at least once. (tsubst): Use fold_decl_constant_value in place of a bare call to integral_constant_value. PR c++/19208 * g++.dg/template/array11.C: New test. From-SVN: r94006
2005-01-17pt.c (tinst_for_decl): Remove.Kazu Hirata1-14/+0
* pt.c (tinst_for_decl): Remove. * cp-tree.h: Remove the corresponding prototypes. From-SVN: r93756
2005-01-07re PR c++/19298 (dependent type (references) and calling a function method)Nathan Sidwell1-0/+2
cp: PR c++/19298 * pt.c (tsubst_qualified_id): Call convert_from_reference. testsuite: PR c++/19298 * g++.dg/template/ref2.C: New. From-SVN: r93055
2005-01-06re PR c++/19258 (Incorrect access check for default argument)Kriang Lerdsuwanakij1-2/+4
PR c++/19258 * pt.c (push_access_scope): Handle friend defined in class. (pop_access_scope): Likewise. * g++.dg/lookup/friend6.C: New test. From-SVN: r92993
2005-01-06re PR c++/19270 (ice on valid template code)Nathan Sidwell1-13/+10
cp: PR c++/19270 * pt.c (tsubst_copy) <ARRAY_REF case>: Handle separately. (tsubst_copy_and_build) <ARRAY_REF case>: Remove obsolete array-new handling code. Use build_x_binary_op. testsuite: PR c++/19270 * g++.dg/template/array10.C: New. From-SVN: r92992
2005-01-05re PR c++/19030 (ice on tree check)Nathan Sidwell1-9/+9
cp: PR c++/19030 * cp-tree.h (start_decl): Take pointer to pushed scope, not bool. * name-lookup.h (push_scope): Return pushed scope, not flag. * name-lookup.c (push_scope): Return scope that should be popped, not a flag. * decl.c (start_decl): Adjust. (grokfndecl): Adjust scope push and pop. * decl2.c (check_classfn): Likewise. * parser.c (cp_parser_condition, cp_parser_conversion_function_id, cp_parser_init_declarator, cp_parser_direct_declarator, cp_parser_class_specifier, cp_parser_class_head, cp_parser_lookup_name, cp_parser_constructor_declarator_p): Likewise. * pt.c (instantiate_class_template, resolve_typename_type): Likewise. testsuite: PR c++/19030 * g++.dg/parse/crash22.C: New From-SVN: r92946
2004-12-23re PR c++/17413 (local classes as template argument)Mark Mitchell1-3/+1
PR c++/17413 * pt.c (check_instantiated_args): Remove bogus SFINAE code. PR c++/17413 * g++.dg/template/local4.C: New test. * g++.dg/template/crash19.C: Add dg-error marker. From-SVN: r92562
2004-12-23re PR c++/18962 (specialization of template class with inner template ↵Alexandre Oliva1-0/+4
members and parameter) gcc/cp/ChangeLog: PR c++/18962 * pt.c (check_explicit_specialization): Use the argument list from the definition in a template function specialization definition. gcc/testsuite/ChangeLog: * g++.dg/template/spec19.C: New. From-SVN: r92552
2004-12-23re PR c++/18733 (friend rejected)Giovanni Bajo1-1/+9
PR c++/18733 * pt.c (check_explicit_specialization): Use special logic to validate befriended specializations. PR c++/18733 * g++.dg/template/friend33.C: New testcase. From-SVN: r92527
2004-12-16re PR c++/18905 (Strange error: subscripted value is neither array nor pointer)Nathan Sidwell1-23/+9
cp: PR c++/18905 * cp-tree.h (integral_constant_value): Declare. * call.c (null_ptr_cst_p): Use integral_constant_value, not decl_constant_value. (convert_like_real): Likewise. * class.c (check_bitfield_decl): Likewise. * cvt.c (ocp_convert): Likewise. (convert): Remove unnecessary decl_constant_value call. * decl.c (compute_array_index_type): Use integral_constant_value, not decl_constant_value. (build_enumerator): Likewise. * decl2.c (grokfield): Likewise. * init.c (decl_constant_value): Simplify. (integral_constant_value): New. * pt.c (fold_decl_constant_value): Use integral_constant_value, remove subsequent check. (tsubst): Use integral_constant_value, not decl_constant_value. (tsubst_copy, unify): Likewise. * typeck.c (decay_conversion): Likewise. (build_compound_expr): Remove unnecessary decl_constant_value calls. (build_static_cast_1, build_reinterpret_cast_1): (convert_for_assignment): Remove comment about not calling decl_constant_value. testsuite: PR c++/18905 * g++.dg/template/init4.C: New. * g++.dg/opt/static3.C: Enable optimizer. From-SVN: r92257
2004-12-15re PR c++/18825 (ICE segmentation fault in wv2)Kriang Lerdsuwanakij1-15/+38
PR c++/18825 * pt.c (instantiate_class_template): Set input_location for friend function. (tsubst_friend_function): Don't set input_location here. Make sure the context is complete if necessary. * g++.dg/template/friend32.C: New test. From-SVN: r92200
2004-12-14re PR c++/18949 (trouble with const_cast in templates)Nathan Sidwell1-2/+5
cp: PR c++/18949 * pt.c (tsubst_copy_and_build): <INDIRECT_REF case> Check that a REFERENCE_REF_P is dereferencing a reference type. * typeck.c (build_static_cast): Convert from reference even in a template. (build_reinterpret_cast, build_const_cast, build_c_cast): Likewise. testsuite: PR c++/18949 * g++.dg/template/cast1.C: New. From-SVN: r92136
2004-12-08re PR c++/18803 (rejects access to operator() in template)Nathan Sidwell1-18/+26
cp: PR c++/18803 * cp-tree.h (REFERENCE_REF_P): New. (CPTI_TYPE_INFO_TYPE): Rename to ... (CPTI_CONST_TYPE_INFO_TYPE): ... here. (CPTI_TYPE_INFO_REF_TYPE): Remove. (type_info_type_node): Rename to ... (const_type_info_type_node): ... here. (type_info_ref_type): Remove. * call.c (build_user_type_conversion): Reformat. (resolve_args): Do not convert_from_reference. (build_object_call): Call convert_from_reference. (prep_operand): Do not convert_from_reference. (build_new_method_call): Likewise. * class.c (build_vfield_ref): Likewise. * cvt.c (convert_to_reference): Likewise. (convert_from_reference): Build INDIRECT_REF here, not with build_indirect_ref. (convert_force): Do not convert_from_reference. (build_expr_type_conversion): Likewise. * decl.c (grok_reference_init): Likewise. * decl2.c (delete_sanity): Likewise. * except.c (initialize_handler_parm): Use POINTER_TYPE_P. * init.c (build_dtor_call): Do not convert_from_reference. * parser.c (cp_parser_template_argument): Unwrap indirected reference. Allow TEMPLATE_PARM_INDEX as an object parm. * pt.c (tsubst_copy_and_build) <case INDIRECT_REF>: Use convert_from_reference, if indicated. <case CALL_EXPR>: Do not convert_from_reference. <case PARM_DECL, VAR_DECL>: Convert_from_reference if needed. (tsubst_initializer_list): Do not convert_from_reference. * rtti.c (init_rtti_processing): Adjust node creation. (throw_bad_typeid): Use const_type_info_type_node. Do not convert_from_reference. (typeid_ok_p): Use const_type_info_type_node. (build_typeid, get_typeid): Always return type_info typed node. (build_dynamic_cast_1): Dont convert_from_reference. Refactor. * semantics.c (finish_stmt_expr_expr): Do not convert_from_reference. (finish_id_expression): Convert_from_reference as appropriate. * typeck.c (decay_conversion): Do not convert_from_reference. (finish_class_member_access_expr): Likewise. (build_indirect_ref): Use POINTER_TYPE_P. (convert_arguments): Do not convert_from_reference. (build_modify_expr): Likewise. (convert_for_initialization): Likewise. * typeck2.c (build_x_arrow): Likewise. testsuite: PR c++/18803 * g++.dg/template/operator5.C: New. From-SVN: r91863
2004-12-07c-common.c, [...]: Replace uses of first_rtl_op with TREE_CODE_LENGTH.Kazu Hirata1-1/+1
gcc/ * c-common.c, expr.c, fold-const.c, print-tree.c, tree-gimple.c, tree-inline.c, tree-pretty-print.c, tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c: Replace uses of first_rtl_op with TREE_CODE_LENGTH. * tree.c (first_rtl_op): Remove. Replace uses of first_rtl_op with TREE_CODE_LENGTH. * tree.h: Remove the prototype for first_rtl_op. gcc/cp/ * pt.c: Replace a use of first_rtl_op with TREE_CODE_LENGTH. From-SVN: r91818
2004-12-04PR c++/17011, c++/17971Kriang Lerdsuwanakij1-2/+13
PR c++/17011, c++/17971 * pt.c (tsubst_copy) <FIELD_DECL case>: Check and diagnose invalid field. (tsubst_copy_and_build) <COMPONENT_REF case>: Check error_mark_node after member substitution. * semantics.c (finish_id_expression): Call finish_non_static_data_member for non-dependent FIELD_DECL. * g++.dg/template/error15.C: Adjust expected error. * g++.dg/template/instantiate3.C: Likewise. From-SVN: r91720
2004-12-02PR c++/15664, c++/18276Kriang Lerdsuwanakij1-34/+42
PR c++/15664, c++/18276 * pt.c (tsubst_decl) <TEMPLATE_DECL case>: Reorganize. Correctly tsubst TEMPLATE_DECL that is a TEMPLATE_TEMPLATE_PARM. * g++.dg/template/ttp13.C: New test. * g++.dg/template/ttp14.C: Likewise. From-SVN: r91633
2004-11-29re PR c++/18368 (C++ error message regression)Mark Mitchell1-26/+50
PR c++/18368 * parser.c (cp_parser_check_for_definition_in_return_type): Take the defined type as a parameter, and inform the user about the possibility of a missing semicolon. (cp_parser_explicit_instantiation): Adjust call to cp_parser_check_for_definition_in_return_type. (cp_parser_init_declarator): Likewise. (cp_parser_member_declaration): Likewise. PR c++/18674 * cp-tree.def (TYPENAME_TYPE): Remove discussion of implicit typename from comments. * cp-tree.h (TYPENAME_IS_ENUM_P): New macro. (TYPENAME_IS_CLASS_P): Likewise. (make_typename_type): Change prototype. * decl.c (struct_typename_info): New type. (typename_compare): Expect the second argument to be a typename_info, not a tree. (build_typename_type): Add tag_type parameter. Do not create a new type until necessary. (make_typename_type): Add tag_type parameter. * error.c (TYPENAME_TYPE): Print tags other than "typename" if appropriate. * friend.c (make_friend_class): Adjust call to make_typename_type. * parser.c (cp_parser_make_typename_type): Likewise. (cp_parser_primary_expression): Adjust call to cp_parser_lookup_name. (cp_parser_unqualified_id): Adjust calls to cp_parser_class_name. (cp_parser_class_or_namespace_name): Likewise. (cp_parser_postfix_expression): Adjust calls to make_typename_type. (cp_parser_mem_initializer_id): Adjust calls to cp_parser_class_name. (cp_parser_type_parameter): Adjust calls to cp_parser_lookup_name. (cp_parser_template_name): Likewise. (cp_parser_template_argument): Likewise. (cp_parser_type_name): Adjust call to cp_parser_class_name. (cp_parser_elaborated_type_specifier): Adjust calls to make_typename_type and cp_parser_lookup_name. (cp_parser_namespace_name): Likewise. (cp_parser_class_name): Replace type_p parameter with tag_type. Adjust calls to make_typename_type and cp_parser_lookup_name. (cp_parser_class_head): Adjust calls to cp_parser_class_name. (cp_parser_base_specifier): Likewise. (cp_parser_lookup_name): Replace is_type parameter with tag_type. Adjust calls to make_typename_type and lookup_qualified_name. (cp_parser_lookup_name_simple): Adjust call to cp_parser_lookup_name. (cp_parser_constructor_declarator_p): Adjust call to cp_parser_class_name. * pt.c (convert_template_argument): Adjust all to make_typename_type. (tsubst_decl): Do not pre-substitute the type of the declaration. (tsubst): Hand off declarations more quickly. Adjust call to make_typename_type. PR c++/18512 * parser.c (cp_parser_postfix_dot_deref_expression): Robustify. PR c++/18674 * g++.old-deja/g++.brendan/crash16.C: Adjust error messages. * g++.old-deja/g++.law/ctors5.C: Likewise. * g++.old-deja/g++.other/crash25.C: Likewise. PR c++/18674 * g++.dg/template/error16.C: New test. PR c++/18512 * g++.dg/template/crash29.C: New test. From-SVN: r91483
2004-11-29re PR c++/18652 (ICE on invalid redeclaration)Kriang Lerdsuwanakij1-1/+5
PR c++/18652 * name-lookup.c (pushtag): Change return type to tree. * cp-tree.h (pushtag): Adjust declaration. * decl.c (xref_tag, start_enum): Use return value of pushtag. * pt.c (push_template_decl_real): Return immediately if pushdecl_namespace_level returns error_mark_node. * g++.dg/lookup/crash6.C: New test. From-SVN: r91470
2004-11-27* pt.c: Fix a comment typo.Kazu Hirata1-1/+1
From-SVN: r91391
2004-11-25re PR c++/18001 (Badly formatted error message (quotation problem))Mark Mitchell1-0/+3
PR c++/18001 * c-common.h (lvalue_use): Move here from c-ctypeck.c. (lvalue_or_else): Declare. * c-common.c (lvalue_or_else): Move here from c-typeck.c. * c-typeck.c (lvalue_use): Remove. (lvalue_or_else): Remove. PR c++/18556 * toplev.c (check_global_declarations): Set DECL_IGNORED_P on unemitted variables with static storage duration. PR c++/18445 * class.c (instantiate_type): Treat NON_DEPENDENT_EXPRs with unknown_type as non matching. Tidy up. * pt.c (build_non_dependent_expr): Do not build a NON_DEPENDENT_EXPR for a VAR_DECL. PR c++/18001 * cp-tree.h (lvalue_or_else): Remove declaration. * tree.c (lvalue_or_else): Remove. * typeck.c (build_unary_op): Adjust call to lvalue_or_else. (build_modify_expr): Likewise. PR c++/18625 * decl.c (duplicate_decls): Return error_mark_node on error, as specified. PR c++/18466 * decl.c (grokvardecl): Keep track of whether or not a there was explicit qualification. * name-lookup.c (set_decl_namespace): Complain about explicit qualification of a name within its own namespace. PR c++/18545 * typeck.c (check_return_expr): Robustify. PR c++/18445 * g++.dg/template/crash28.C: Likewise. PR c++/18001 * g++.dg/expr/unary2.C: Adjust lvalue messages. * g++.dg/ext/lvaddr.C: Likewise. * g++.dg/opt/pr7503-3.C: Likewise. PR c++/18466 * g++.dg/parse/qualified3.C: New test. * g++.old-deja/g++.other/friend7.C: Remove bogus qualification. PR c++/18545 * g++.dg/expr/return1.C: New test. From-SVN: r91301
2004-11-25Friend class name lookup 2/n, PR c++/14513, c++/15410Kriang Lerdsuwanakij1-2/+3
Friend class name lookup 2/n, PR c++/14513, c++/15410 * name-lookup.c (lookup_name_real): Simplify. (lookup_type_scope): Add SCOPE parameter. Handle friend class lookup. * name-lookup.h (tag_scope): New enum type. (lookup_type_scope): Adjust declaration. * decl.c (lookup_and_check_tag, xref_tag, xref_tag_from_type): Change bool parameter GLOBALIZED to TAG_SCOPE parameter SCOPE. (start_enum): Likewise. Add assertion test that NAME is IDENTIFIER_NODE. Use anonymous name for dummy ENUMERAL_TYPE in case of error. * cp-tree.h (xref_tag, xref_tag_from_type): Adjust declarations. * parser.c (cp_parser_elaborated_type_specifier, cp_parser_class_head): Adjust call to xref_tag. * pt.c (lookup_template_class, instantiate_class_template): Likewise. * rtti.c (init_rtti_processing, build_dynamic_cast_1, tinfo_base_init, emit_support_tinfos): Likewise. * g++.dg/lookup/friend2.C: New test. * g++.dg/template/friend31.C: Likewise. From-SVN: r91299
2004-11-24pt.c (tsubst_function_type): Do not permit function types which return ↵Mark Mitchell1-0/+16
arrays or functions. * pt.c (tsubst_function_type): Do not permit function types which return arrays or functions. * g++.dg/template/deduce3.C: New test. From-SVN: r91186
2004-11-14re PR c++/17344 (completely wacky error with matching template template ↵Kriang Lerdsuwanakij1-1/+4
classes and default arguments) PR c++/17344 * pt.c (coerce_template_parms): Only emit error message about invalid template argument when TF_ERROR. * g++.dg/template/defarg5.C: New test. From-SVN: r90615
2004-11-12re PR c++/18389 (ICE on struct declaration in for statement)Mark Mitchell1-4/+13
PR c++/18389 * decl.c (start_decl): Make sure to set *pop_scope_p. Return error_mark_node to indicate errors. PR c++/18429 * parser.c (cp_parser_direct_declarator): Disallow non-constant array bounds when not inside a function. PR c++/18436 * pt.c (tsubst_copy_and_build): Do not do Koenig lookup when an unqualified name resolves to a member function. PR c++/18407 * pt.c (tsubst_copy_and_build): Handle qualified names used from a derived class correctly. * decl2.c (import_export_decl): Fix typo in comment. * tree.c (pod_type_p): Likewise. PR c++/18389 * g++.dg/parse/cond1.C: New test. PR c++/18429 * g++.dg/template/array9.C: New test. * g++.dg/ext/vla1.C: Adjust error messages. * g++.dg/ext/vlm1.C: Likewise. * g++.dg/template/crash2.C: Likewise. PR c++/18436 * g++.dg/template/call3.C: New test. PR c++/18407 * g++.dg/template/ptrmem11.C: New test. From-SVN: r90545
2004-11-09builtins.c, [...]: Avoid "`" as left quote, using "'" or %q, %< and %> as ↵Joseph Myers1-2/+2
appropriate. * builtins.c, c-common.c, c-decl.c, c-format.c, c-format.h, c-parse.in, c-pch.c, c-pragma.c, collect2.c, final.c, gcc.c, gcov.c, opts.c, pretty-print.h, protoize.c, reg-stack.c, rtl.c, tlink.c, config/alpha/alpha.c, config/arc/arc.c, config/arm/arm.c, config/avr/avr.c, config/c4x/c4x.c, config/darwin.c, config/frv/frv.c, config/h8300/h8300.c, config/i386/i386.c, config/i386/winnt.c, config/ia64/ia64.c, config/ip2k/ip2k.c, config/iq2000/iq2000.c, config/m32r/m32r.c, config/m68hc11/m68hc11.c, config/m68k/m68k.c, config/m68k/m68k.h, config/mcore/mcore.c, config/mips/mips.c, config/mmix/mmix.c, config/ns32k/ns32k.c, config/rs6000/host-darwin.c, config/rs6000/rs6000.c, config/s390/s390.c, config/sh/sh.c, config/sh/symbian.c, config/stormy16/stormy16.c, config/v850/v850.c: Avoid "`" as left quote, using "'" or %q, %< and %> as appropriate. Use %' as apostrophe in diagnostics where applicable. Use %< and %> in place of '' quotes where applicable. Use %qs in place of %<%s%>. Consistently quote __builtin function names. ada: * misc.c (gnat_handle_option): Use %< and %> for quoting in warning message. cp: * call.c, class.c, decl.c, decl2.c, error.c, mangle.c, parser.c, pt.c, search.c, semantics.c, typeck.c: Use %q, %< and %> for quoting in diagnostics. * parser.c (cp_parser_sizeof_operand): Use '' instead of `' for quoting in printf format. * decl.c (duplicate_decls, start_decl): Use %qD instead of unquoted %D. objc: * objc-act.c: Use %q, %< and %> for quoting in diagnostics. testsuite: * gcc.dg/builtin-prefetch-1.c: Adjust expected messages. From-SVN: r90337
2004-11-08class.c, [...]: Fix comment formatting.Kazu Hirata1-4/+4
* class.c, decl.c, lex.c, name-lookup.c, parser.c, pt.c, search.c, typeck2.c: Fix comment formatting. From-SVN: r90265
2004-11-04DR 49, 100Giovanni Bajo1-329/+322
DR 49, 100 * cp-tree.h (TYPE_REF_OBJ_P): New macro. (TYPE_PTR_P, TYPE_PTROB_P, TYPE_PTROBV_P, TYPE_PTRFN_P, TYPE_REFFN_P): Document. (fold_decl_constant_value): New prototype. * pt.c (convert_nontype_argument_function): Rewrite and extract parts into... (fold_decl_constant_value, convert_nontype_argument_function): New. (lookup_template_class): Add comment about useless double call. * mangle.c (write_expression): Strip conversions before lowering pointer to members. * cvt.c (ocp_convert): Check LOOKUP_COMPLAIN for a pedwarn. Disallow enum to enum conversion. * g++.dg/template/nontype7.C: New test. * g++.dg/template/nontype8.C: Likewise. * g++.dg/template/nontype9.C: Likewise. * g++.dg/template/nontype10.C: Likewise. * g++.dg/tc1/dr49.C: Likewise. * g++.dg/template/ptrmem8.C: Relax dg-error checks. * g++.old-deja/g++.other/null1.C: Remove a buggy error check From-SVN: r90059
2004-11-01Convert diagnostics to use quoting flag q 9/nGabriel Dos Reis1-1/+1
Convert diagnostics to use quoting flag q 9/n * typeck.c (build_x_unary_op, convert_member_func_to_ptr, get_delta_difference): Use new quotation style. * repo.c (reopen_repo_file_for_write): Likewise. * pt.c (do_type_instantiation): Likewise. * parser.c (cp_parser_diagnose_invalid_type_name): * name-lookup.c (push_overloaded_decl, set_decl_namespace): * error.c (cp_print_error_function, print_instantiation_full_context): Likewise. * decl.c (define_label, grok_reference_init, maybe_deduce_size_from_array_init, revert_static_member_fn): * decl2.c (check_classfn): Likewise. * class.c (add_method, check_field_decls, layout_class_type, resolve_address_of_overloaded_function): Likewise. * call.c (build_x_va_arg, build_over_call): Likewise. From-SVN: r89938
2004-10-29* pt.c: Fix a comment typo.Kazu Hirata1-1/+1
From-SVN: r89845
2004-10-28re PR c++/17132 (GCC fails to eliminate function template specialization ↵Mark Mitchell1-2/+16
when argument deduction fails) PR c++/17132 * pt.c (instantiate_class_template): Increment processing_template_decl when substituting into a member class template. PR c++/17132 * g++.dg/template/memclass3.C: New test. From-SVN: r89778
2004-10-27re PR c++/18093 (bogus conflict in namespace aliasing)Mark Mitchell1-0/+8
PR c++/18093 * search.c (current_scope): Return the innermost non-block scope, not the innermost non-block, non-namespace scope. (at_namespace_scope_p): Adjust accordingly. (dfs_accessible_post): Do not pass namespaces to is_friend. (dfs_walk_once_accessible_r): Likewise. * decl.c (grokvardecl): Adjust call to current_scope. (build_enumerator): Likewise. * parser.c (cp_parser_using_declaration): Likewise. (cp_parser_direct_declarator): Use at_namespace_scope_p instead of current_scope. (cp_parser_class_head): Adjust call to current_scope. * name-lookup.c (do_namespace_alias): Set the DECL_CONTEXT for the alias. PR c++/18020 * pt.c (tusbst_copy_and_build): Resolve enumeration constants to their underlying values. PR c++/18161 * typeck.c (build_binary_op): Honor build_type, even when in a template. PR c++/18093 * g++.dg/lookup/ns2.C: New test. PR c++/18020 * g++.dg/template/enum4.C: New test. PR c++/18161 * g++.dg/template/expr1.C: New test. From-SVN: r89627
2004-10-20re PR c++/13495 (Friendship to class nested within a template is broken)Kriang Lerdsuwanakij1-25/+97
PR c++/13495 * decl.c (make_unbound_class_template): Add PARM_LIST parameter. * cp-tree.h (make_unbound_class_template): Adjust prototype. * parser.c (cp_parser_lookup_name): Adjust call to make_unbound_class_template. (cp_parser_single_declaration): Handle member class of class template as template friend parsing correctly. * friend.c (is_friend): Call is_specialization_of_friend for template friend class. (make_friend_class): Handle member class of class template as template friend. * pt.c (is_specialization_of_friend): Likewise. (instantiate_class_template): Likewise. (tsubst): Adjust call to make_unbound_class_template. * g++.dg/template/memfriend9.C: New test. * g++.dg/template/memfriend10.C: Likewise. * g++.dg/template/memfriend11.C: Likewise. * g++.dg/template/memfriend12.C: Likewise. * g++.dg/template/memfriend13.C: Likewise. * g++.dg/template/memfriend14.C: Likewise. * g++.dg/template/memfriend15.C: Likewise. * g++.dg/template/memfriend16.C: Likewise. * g++.dg/template/memfriend17.C: Likewise. * g++.old-deja/g++.pt/friend44.C: Remove bogus error. From-SVN: r89335
2004-10-14Speed up walk_tree by introducing a special-purpose hash table.Matt Austern1-6/+11
* pointer-set.c: New file, special-purpose hash table. * pointer-set.h: New file. * tree.h (struct pointer_set_t): Declare as opaque type. (tree_walk): Last argument is pointer_set_t* now. * tree-inline.c (WALK_SUBTREE): Convert from htab to pset. (walk_type_fields): (walk_tree): Convert from htab_t to pointer_set_t for keeping track of which nodes have already been visited. (walk_tree_without_duplicates): Convert from htab_t to pointer_set_t. * cgraphunit.c (cgraph_create_edges): Likewise. (cgraph_characterize_statics_local): Likewise. * tree-dfa.c (collect_dfa_stats): Likewise. * langhooks-def.h (lhd_tree_inlining_walk_subtrees): Last arg is pointer_set_t* now. * langhooks.c (lhd_tree_inlining_walk_subtrees): Likewise. * langhooks.h (struct lang_hooks_for_tree_inlining): Last arg type of walk_subtrees is pointer_set_t* now. * Makefile.in (OBJS-common): add pointer-set.o (tree-inline.o): Depends on pointer-set.h (tree-dfa.o): Likewise (cgraphunit.o): Likewise * cp/Make-lang.in (pt.o): depends on pointer-set.h * cp/cp-tree.h (cp_walk_subtrees): Last argument is pointer_set_t* now. * cp/pt.c (struct pair_fn_data): Use pointer_set_t, not htab_t (for_each_template_parm): Convert from htab_t to pointer_set_t. * cp/tree.c (cp_walk_subtrees): Last argument is pointer_set_t* now. * java/lang.c (java_tree_inlining_walk_subtrees): Last arg is struct pointer_set_t* now. From-SVN: r89062
2004-10-11re PR c++/17936 (Declaration of specialization rejected)Mark Mitchell1-0/+6
PR c++/17936 * cp-tree.h (CLASSTYPE_TEMPLATE_SPECIALIZATION): Add a comment. * pt.c (optimize_specialization_lookup_p): Do not optimize lookups for members of partial or explicit specializations. PR c++/17936 * g++.dg/template/spec18.C: New test. From-SVN: r88905
2004-10-09re PR c++/17524 (ICE with initializing a variable of type void)Mark Mitchell1-3/+1
PR c++/17524 * cp-tree.h (check_var_type): New function. * decl.c (check_var_type): New function, split out from ... (grokdeclarator): ... here. * pt.c (tsubst_decl): Use check_var_type. PR c++/17685 * decl.c (grokdeclarator): Disallow declarations of operators as PR c++/17524 * g++.dg/template/static9.C: New test. PR c++/17685 * g++.dg/parse/operator5.C: New test. From-SVN: r88820
2004-10-08* pt.c, search.c: Fix comment typos.Kazu Hirata1-2/+2
From-SVN: r88749
2004-10-07pt.c (tsubst_expr): Look passed the CLEANUP_POINT_EXPR to get the asm ↵Andrew Pinski1-1/+6
expression. 2004-10-07 Andrew Pinski <pinskia@physics.uc.edu> * pt.c (tsubst_expr) <case ASM_EXPR>: Look passed the CLEANUP_POINT_EXPR to get the asm expression. From-SVN: r88733
2004-10-07cp-tree.h (ICS_USER_FLAG): Remove comment about obsolete flag.Mark Mitchell1-236/+281
* cp-tree.h (ICS_USER_FLAG): Remove comment about obsolete flag. (DECL_MEMBER_TEMPLATE_P): New macro. (is_member_template): Remove. (class_method_index_for_fn): New function. * pt.c (build_over_call): Use DECL_MEMBER_TEMPLATE_P. * class.c (finish_struct_methods): Remove out-of-date comment. * decl.c (copy_fn_p): Use DECL_MBMER_TEMPLATE_P. * decl2.c (check_classfn): Use DECL_MEMBER_TEMPLATE_P and class_method_index_for_fn. * pt.c (is_member_template): Remove. (is_member_template_class): Likewise. (optimize_specialization_lookup_p): New function. (retrieve_specialization): Optimize lookups for members that are not member templates. (register_specialization): Adjust accordingly. (build_template_decl): Add member_template_p parameter. Set DECL_MEMBER_TEMPLATE_P. (process_partial_specialization): Adjust call to retrieve_specialization. (push_template_decl_real): Determine whether the template is a member template. (lookup_template_class): Use retrieve_specialization. (tsubst_decl): Adjust call to retrieve_specialization. (tsubst_exception_specification): New function. (tsubst): Use it. (tsubst_copy): Use DECL_MEMBER_TEMPLATE_P. (instantiate_template): Adjust call to retrieve_specialization. (regenerate_decl_from_template): Do not actually generate a new DECL. (instantiate_decl): Adjust call to retrieve_specialization. (class_method_index_for_fn): New method. From-SVN: r88697
2004-10-05Convert diagnostics to use quoting flag q 6/nGabriel Dos Reis1-133/+134
Convert diagnostics to use quoting flag q 6/n * pt.c (finish_member_template_decl, check_specialization_scope, maybe_process_partial_specialization, determine_specialization, check_explicit_specialization, maybe_check_template_type, process_partial_specialization, check_default_tmpl_args, push_template_decl_real, redeclare_class_template, convert_nontype_argument, coerce_template_parms, lookup_template_class, push_tinst_level, instantiate_class_template, tsubst_arg_types, tsubst_function_type, tsubst, tsubst_qualified_id, tsubst_copy_and_build, check_instantiated_args, do_decl_instantiation, do_type_instantiation, invalid_nontype_parm_type_p, check_specialization_namespace, convert_template_argument, determine_specialization, check_template_shadow, tsubst_decl instantiate_pending_templates): Use quoting marks. From-SVN: r88573
2004-09-28class.c (VTT_TOP_LEVEL_P, [...]): Remove.Nathan Sidwell1-58/+24
* class.c (VTT_TOP_LEVEL_P, VTT_MARKED_BINFO_P): Remove. (struct secondary_vptr_vtt_init_data_s): New. (build_vtt_inits): Adjust dfs_walkers. (dfs_build_secondary_vptr_vtt_inits): Caller data is a secondary_vptr_vtt_init_data_s structure. Adjust. (dfs_ctor_vtable_bases_queue_p): Remove. (dfs_fixup_binfo_vtbls): No need to clear BINFO_MARKED. Simplify. * pt.c (struct get_template_base_data_s): Remove. (get_template_base_r): Fold into get_template_base. (get_template_base): Walk base binfos directly in inheritance graph order. Remove duplicated changelog entries From-SVN: r88224