Commit 1b8899d1 by Mark Mitchell

class.c (finish_struct_1): Look at the const-ness of the field's type...

	* class.c (finish_struct_1): Look at the const-ness of the field's
	type, not the TREE_READONLY-ness of the declaration.
	* method.c (synthesize_method): Likewise.
	* pt.c (tsubst_decl): Call c_apply_type_quals_to_decl when
	creating new declarations.

From-SVN: r26420
parent adfaf194
1999-04-13 Mark Mitchell <mark@codesourcery.com>
* class.c (finish_struct_1): Look at the const-ness of the field's
type, not the TREE_READONLY-ness of the declaration.
* method.c (synthesize_method): Likewise.
* pt.c (tsubst_decl): Call c_apply_type_quals_to_decl when
creating new declarations.
1999-04-13 Mike Stump <mrs@wrs.com> 1999-04-13 Mike Stump <mrs@wrs.com>
* decl2.c (import_export_decl): Because vtables always reference * decl2.c (import_export_decl): Because vtables always reference
...@@ -255,12 +263,23 @@ Wed Mar 31 11:30:43 BST 1999 Nathan Sidwell <nathan@acm.org> ...@@ -255,12 +263,23 @@ Wed Mar 31 11:30:43 BST 1999 Nathan Sidwell <nathan@acm.org>
* parse.y (declmods, nonempty_cv_qualifiers): Use hash_tree_cons. * parse.y (declmods, nonempty_cv_qualifiers): Use hash_tree_cons.
Wed Mar 31 10:48:29 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> Wed Mar 31 10:48:29 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
<<<<<<< ChangeLog
* Makefile.in (hash.h): Generate using gperf language 'C', not
'KR-C', so gperf uses the `const' keyword on strings.
* gxx.gperf (resword): Const-ify a char*.
=======
* Makefile.in (hash.h): Generate using gperf language 'C', not * Makefile.in (hash.h): Generate using gperf language 'C', not
'KR-C', so gperf uses the `const' keyword on strings. 'KR-C', so gperf uses the `const' keyword on strings.
>>>>>>> 1.988
<<<<<<< ChangeLog
=======
* gxx.gperf (resword): Const-ify a char*. * gxx.gperf (resword): Const-ify a char*.
>>>>>>> 1.988
1999-03-30 Jason Merrill <jason@yorick.cygnus.com> 1999-03-30 Jason Merrill <jason@yorick.cygnus.com>
* cp-tree.h (IDENTIFIER_AS_DESC, IDENTIFIER_AS_LIST, * cp-tree.h (IDENTIFIER_AS_DESC, IDENTIFIER_AS_LIST,
...@@ -7109,15 +7128,29 @@ Fri Mar 6 23:27:35 1998 Jeffrey A Law (law@cygnus.com) ...@@ -7109,15 +7128,29 @@ Fri Mar 6 23:27:35 1998 Jeffrey A Law (law@cygnus.com)
* method.c: Fix typo. * method.c: Fix typo.
Fri Mar 6 10:06:59 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> Fri Mar 6 10:06:59 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
<<<<<<< ChangeLog
=======
* method.c: Include "system.h" to get stdlib.h, stdio.h, * method.c: Include "system.h" to get stdlib.h, stdio.h,
ctype.h, string.h, etc. ctype.h, string.h, etc.
(issue_nrepeats): Add default case in enumeration switch. (issue_nrepeats): Add default case in enumeration switch.
(check_btype): Likewise. (check_btype): Likewise.
(process_overload_item): Likewise. (process_overload_item): Likewise.
>>>>>>> 1.988
<<<<<<< ChangeLog
* method.c: Include "system.h" to get stdlib.h, stdio.h,
ctype.h, string.h, etc.
(issue_nrepeats): Add default case in enumeration switch.
(check_btype): Likewise.
(process_overload_item): Likewise.
* Makefile.in (method.o): Depend on system.h. * Makefile.in (method.o): Depend on system.h.
=======
* Makefile.in (method.o): Depend on system.h.
>>>>>>> 1.988
Wed Mar 4 22:26:53 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> Wed Mar 4 22:26:53 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* lex.c (do_scoped_id): Fix parenthesizing. * lex.c (do_scoped_id): Fix parenthesizing.
...@@ -9101,6 +9134,23 @@ Sat Sep 27 16:22:48 1997 Jason Merrill <jason@yorick.cygnus.com> ...@@ -9101,6 +9134,23 @@ Sat Sep 27 16:22:48 1997 Jason Merrill <jason@yorick.cygnus.com>
(notype_qualified_id): Don't add template declarators here. (notype_qualified_id): Don't add template declarators here.
Sat Sep 27 16:21:58 1997 Mark Mitchell <mmitchell@usa.net> Sat Sep 27 16:21:58 1997 Mark Mitchell <mmitchell@usa.net>
<<<<<<< ChangeLog
* call.c (add_template_candidate): Add explicit_targs parameter.
(build_scoped_method_call): Use it.
(build_overload_call_real): Likewise.
(build_user_type_conversion_1): Likewise.
(build_new_function_call): Likewise.
(build_object_call): Likewise.
(build_new_op): Likewise.
(build_new_method_call): Likewise.
(build_new_function_call): Handle TEMPLATE_ID_EXPR.
(build_new_method_call): Likewise.
* class.c (finish_struct_methods): Add specialization pass to
determine which methods were specializing which other methods.
(instantiate_type): Handle TEMPLATE_ID_EXPR.
=======
* call.c (add_template_candidate): Add explicit_targs parameter. * call.c (add_template_candidate): Add explicit_targs parameter.
(build_scoped_method_call): Use it. (build_scoped_method_call): Use it.
...@@ -9112,15 +9162,25 @@ Sat Sep 27 16:21:58 1997 Mark Mitchell <mmitchell@usa.net> ...@@ -9112,15 +9162,25 @@ Sat Sep 27 16:21:58 1997 Mark Mitchell <mmitchell@usa.net>
(build_new_method_call): Likewise. (build_new_method_call): Likewise.
(build_new_function_call): Handle TEMPLATE_ID_EXPR. (build_new_function_call): Handle TEMPLATE_ID_EXPR.
(build_new_method_call): Likewise. (build_new_method_call): Likewise.
>>>>>>> 1.988
<<<<<<< ChangeLog
* cp-tree.def (TEMPLATE_ID_EXPR): New tree code.
=======
* class.c (finish_struct_methods): Add specialization pass to * class.c (finish_struct_methods): Add specialization pass to
determine which methods were specializing which other methods. determine which methods were specializing which other methods.
(instantiate_type): Handle TEMPLATE_ID_EXPR. (instantiate_type): Handle TEMPLATE_ID_EXPR.
>>>>>>> 1.988
<<<<<<< ChangeLog
* cp-tree.h (name_mangling_version): New variable.
=======
* cp-tree.def (TEMPLATE_ID_EXPR): New tree code. * cp-tree.def (TEMPLATE_ID_EXPR): New tree code.
* cp-tree.h (name_mangling_version): New variable. * cp-tree.h (name_mangling_version): New variable.
>>>>>>> 1.988
(flag_guiding_decls): Likewise. (flag_guiding_decls): Likewise.
<<<<<<< ChangeLog
(build_template_decl_overload): New function. (build_template_decl_overload): New function.
(begin_specialization): Likewise. (begin_specialization): Likewise.
(reset_specialization): Likewise. (reset_specialization): Likewise.
...@@ -9140,20 +9200,119 @@ Sat Sep 27 16:21:58 1997 Mark Mitchell <mmitchell@usa.net> ...@@ -9140,20 +9200,119 @@ Sat Sep 27 16:21:58 1997 Mark Mitchell <mmitchell@usa.net>
* decl2.c (lang_decode_option): Handle -fname-mangling-version. * decl2.c (lang_decode_option): Handle -fname-mangling-version.
(build_expr_from_tree): Handle TEMPLATE_ID_EXPR. (build_expr_from_tree): Handle TEMPLATE_ID_EXPR.
(check_classfn): Handle specializations. (check_classfn): Handle specializations.
=======
(build_template_decl_overload): New function.
(begin_specialization): Likewise.
(reset_specialization): Likewise.
(end_specialization): Likewise.
(determine_explicit_specialization): Likewise.
(check_explicit_specialization): Likewise.
(lookup_template_function): Likewise.
(fn_type_unification): Add explicit_targs parameter.
(type_unification): Likewise.
* decl.c (duplicate_decls): Add smarts for explicit
specializations.
(grokdeclarator): Handle TEMPLATE_ID_EXPR, and function
specializations.
(grokfndecl): Call check_explicit_specialization.
* decl2.c (lang_decode_option): Handle -fname-mangling-version.
(build_expr_from_tree): Handle TEMPLATE_ID_EXPR.
(check_classfn): Handle specializations.
>>>>>>> 1.988
<<<<<<< ChangeLog
* error.c (dump_function_name): Print specialization arguments.
=======
* error.c (dump_function_name): Print specialization arguments. * error.c (dump_function_name): Print specialization arguments.
>>>>>>> 1.988
<<<<<<< ChangeLog
* friend.c (do_friend): Don't call pushdecl for template
instantiations.
=======
* friend.c (do_friend): Don't call pushdecl for template * friend.c (do_friend): Don't call pushdecl for template
instantiations. instantiations.
>>>>>>> 1.988
<<<<<<< ChangeLog
* init.c (build_member_call): Handle TEMPLATE_ID_EXPR.
* lang-options.h: Add -fname-mangling-version, -fguiding-decls,
=======
* init.c (build_member_call): Handle TEMPLATE_ID_EXPR. * init.c (build_member_call): Handle TEMPLATE_ID_EXPR.
* lang-options.h: Add -fname-mangling-version, -fguiding-decls, * lang-options.h: Add -fname-mangling-version, -fguiding-decls,
>>>>>>> 1.988
and -fno-guiding-decls. and -fno-guiding-decls.
<<<<<<< ChangeLog
* lex.c (identifier_type): Return PFUNCNAME for template function * lex.c (identifier_type): Return PFUNCNAME for template function
names. names.
=======
* lex.c (identifier_type): Return PFUNCNAME for template function
names.
>>>>>>> 1.988
<<<<<<< ChangeLog
* method.c (build_decl_overload_real): New function.
(build_template_parm_names): New function.
(build_overload_identifier): Use it.
(build_underscore_int): New function.
(build_overload_int): Use it. Add levels for template
parameters.
(build_overload_name): Likewise. Also, handle TYPENAME_TYPEs.
(build_overload_nested_names): Handle template type parameters.
(build_template_decl_overload): New function.
* parse.y (YYSTYPE): New ntype member.
(nested_name_specifier): Use it.
(nested_name_specifier_1): Likewise.
(PFUNCNAME): New token.
(template_id, object_template_id): New non-terminals.
(template_parm_list): Note specializations.
(template_def): Likewise.
(structsp): Likewise.
(fn.def2): Handle member template specializations.
(component_decl_1): Likewise.
(direct_notype_declarator): Handle template-ids.
(component_decl_1): Likewise.
(direct_notype_declarator): Handle template-ids.
(primary): Handle TEMPLATE_ID_EXPR, and template-ids.
* pt.c (processing_specializations): New variable.
(template_header_count): Likewise.
(type_unification_real): New function.
(processing_explicit_specialization): Likewise.
(note_template_header): Likewise.
(is_member_template): Handle specializations.
(end_template_decl): Call reset_specialization.
(push_template_decl): Handle member template specializations.
(tsubst): Likewise.
(tsubst_copy): Handle TEMPLATE_ID_EXPR.
(instantiate_template): Handle specializations.
(instantiate_decl): Likewise.
(fn_type_unification): Handle explicit_targs.
(type_unification): Likewise. Allow incomplete unification
without an error message, if allow_incomplete.
(get_bindings): Use new calling sequence for fn_type_unification.
* spew.c (yylex): Handle PFUNCNAME.
* tree.c (is_overloaded_fn): Handle TEMPLATE_ID_EXPR.
(really_overloaded_fn): Likewise.
(get_first_fn): Handle function templates.
* typeck.c (build_x_function_call): Use really_overloaded_fn.
Handle TEMPLATE_ID_EXPR.
(build_x_unary_op): Likewise.
(build_unary_op): Likewise.
(mark_addressable): Templates whose address is taken are marked
as used.
=======
* method.c (build_decl_overload_real): New function. * method.c (build_decl_overload_real): New function.
(build_template_parm_names): New function. (build_template_parm_names): New function.
(build_overload_identifier): Use it. (build_overload_identifier): Use it.
...@@ -9209,6 +9368,7 @@ Sat Sep 27 16:21:58 1997 Mark Mitchell <mmitchell@usa.net> ...@@ -9209,6 +9368,7 @@ Sat Sep 27 16:21:58 1997 Mark Mitchell <mmitchell@usa.net>
(mark_addressable): Templates whose address is taken are marked (mark_addressable): Templates whose address is taken are marked
as used. as used.
>>>>>>> 1.988
1997-09-25 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> 1997-09-25 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* decl.c (init_decl_processing): Declare __builtin_constant_p as * decl.c (init_decl_processing): Declare __builtin_constant_p as
......
...@@ -3385,7 +3385,7 @@ finish_struct_1 (t, warn_anon) ...@@ -3385,7 +3385,7 @@ finish_struct_1 (t, warn_anon)
has_mutable = 1; has_mutable = 1;
/* If any field is const, the structure type is pseudo-const. */ /* If any field is const, the structure type is pseudo-const. */
if (TREE_READONLY (x)) if (CP_TYPE_CONST_P (TREE_TYPE (x)))
{ {
C_TYPE_FIELDS_READONLY (t) = 1; C_TYPE_FIELDS_READONLY (t) = 1;
if (DECL_INITIAL (x) == NULL_TREE) if (DECL_INITIAL (x) == NULL_TREE)
......
...@@ -2357,7 +2357,7 @@ do_build_assign_ref (fndecl) ...@@ -2357,7 +2357,7 @@ do_build_assign_ref (fndecl)
if (TREE_CODE (field) != FIELD_DECL) if (TREE_CODE (field) != FIELD_DECL)
continue; continue;
if (TREE_READONLY (field)) if (CP_TYPE_CONST_P (TREE_TYPE (field)))
{ {
if (DECL_NAME (field)) if (DECL_NAME (field))
cp_error ("non-static const member `%#D', can't use default assignment operator", field); cp_error ("non-static const member `%#D', can't use default assignment operator", field);
......
...@@ -5694,6 +5694,8 @@ tsubst_decl (t, args, type, in_decl) ...@@ -5694,6 +5694,8 @@ tsubst_decl (t, args, type, in_decl)
{ {
r = copy_node (t); r = copy_node (t);
TREE_TYPE (r) = type; TREE_TYPE (r) = type;
c_apply_type_quals_to_decl (CP_TYPE_QUALS (type), r);
if (TREE_CODE (DECL_INITIAL (r)) != TEMPLATE_PARM_INDEX) if (TREE_CODE (DECL_INITIAL (r)) != TEMPLATE_PARM_INDEX)
DECL_INITIAL (r) = TREE_TYPE (r); DECL_INITIAL (r) = TREE_TYPE (r);
else else
...@@ -5716,12 +5718,12 @@ tsubst_decl (t, args, type, in_decl) ...@@ -5716,12 +5718,12 @@ tsubst_decl (t, args, type, in_decl)
case FIELD_DECL: case FIELD_DECL:
{ {
r = copy_node (t); r = copy_node (t);
TREE_TYPE (r) = type;
copy_lang_decl (r); copy_lang_decl (r);
#if 0 TREE_TYPE (r) = type;
DECL_FIELD_CONTEXT (r) = tsubst (DECL_FIELD_CONTEXT (t), args, c_apply_type_quals_to_decl (CP_TYPE_QUALS (type), r);
/*complain=*/1, in_decl);
#endif /* We don't have to set DECL_CONTEXT here; it is set by
finish_member_declaration. */
DECL_INITIAL (r) = tsubst_expr (DECL_INITIAL (t), args, DECL_INITIAL (r) = tsubst_expr (DECL_INITIAL (t), args,
/*complain=*/1, in_decl); /*complain=*/1, in_decl);
TREE_CHAIN (r) = NULL_TREE; TREE_CHAIN (r) = NULL_TREE;
...@@ -5767,6 +5769,7 @@ tsubst_decl (t, args, type, in_decl) ...@@ -5767,6 +5769,7 @@ tsubst_decl (t, args, type, in_decl)
r = copy_node (t); r = copy_node (t);
TREE_TYPE (r) = type; TREE_TYPE (r) = type;
c_apply_type_quals_to_decl (CP_TYPE_QUALS (type), r);
DECL_CONTEXT (r) = ctx; DECL_CONTEXT (r) = ctx;
if (TREE_STATIC (r)) if (TREE_STATIC (r))
DECL_ASSEMBLER_NAME (r) DECL_ASSEMBLER_NAME (r)
......
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
template <class T>
struct S {
S();
T t;
};
void f()
{
S<const int> s;
s = s; // ERROR - generated assignment operator is illegal
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment