From 86052cc3d8e276609904697ebb3db98cf67c5e11 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 28 Jan 1998 06:43:39 -0500 Subject: [PATCH] cp-tree.h (grok_enum_decls): Remove type parameter. * cp-tree.h (grok_enum_decls): Remove type parameter. * decl.c (grok_enum_decls): Likewise. * decl2.c (grok_x_components): Call grok_enum_decls unconditionally, since it will do nothing if there is no current_local_enum. Use the new calling sequence. * pt.c (tsubst_enum): Use the new calling sequence for grok_enum_decls. * decl.c (start_function): Make member functions of local classes in extern inline functions have comdat linkage here... (grokdeclarator): Rather than here. * pt.c (convert_nontype_argument): Use decl_constant_value. From-SVN: r17531 --- gcc/cp/ChangeLog | 19 +++++++++++++++++++ gcc/cp/cp-tree.h | 2 +- gcc/cp/decl.c | 23 ++++++++++------------- gcc/cp/decl2.c | 15 +++++++-------- gcc/cp/pt.c | 13 ++++++++----- 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 355cb249455..42bc3ea04e2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,21 @@ +Wed Jan 28 11:04:07 1998 Mark Mitchell + + * cp-tree.h (grok_enum_decls): Remove type parameter. + * decl.c (grok_enum_decls): Likewise. + * decl2.c (grok_x_components): Call grok_enum_decls + unconditionally, since it will do nothing if there is no + current_local_enum. Use the new calling sequence. + * pt.c (tsubst_enum): Use the new calling sequence for + grok_enum_decls. + + * decl.c (start_function): Make member functions of local classes + in extern inline functions have comdat linkage here... + (grokdeclarator): Rather than here. + +Wed Jan 28 10:55:47 1998 Jason Merrill + + * pt.c (convert_nontype_argument): Use decl_constant_value. + Tue Jan 27 16:42:21 1998 Mark Mitchell * call.c (add_template_candidate_real): New function. @@ -13,6 +31,7 @@ Tue Jan 27 16:42:21 1998 Mark Mitchell (check_explicit_specialization): Return a tree, not an int. (more_specialized): Take additional argument. (get_bindings): Likewise. + (TI_PENDING_SPECIALIZATION_FLAG): New macro. * cvt.c (perform_qualification_conversions): Use comp_ptr_ttypes. (perform_array_to_pointer_conversion): Remove. * decl.c (saved_scope): Add processing_specialization, diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 7354ba9cecf..85225da7393 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2099,7 +2099,7 @@ extern void xref_basetypes PROTO((tree, tree, tree, tree)); extern tree start_enum PROTO((tree)); extern tree finish_enum PROTO((tree, tree)); extern tree build_enumerator PROTO((tree, tree)); -extern tree grok_enum_decls PROTO((tree, tree)); +extern tree grok_enum_decls PROTO((tree)); extern int start_function PROTO((tree, tree, tree, int)); extern void expand_start_early_try_stmts PROTO((void)); extern void store_parm_decls PROTO((void)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 700ce08b95e..fdac895ef2d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9734,16 +9734,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) funcdef_flag, template_count); if (decl == NULL_TREE) return NULL_TREE; - if (function_context != NULL_TREE - && DECL_THIS_INLINE (function_context) - && TREE_PUBLIC (function_context)) - /* We just declared a member of a local class in an - extern inline function. Give such an entity comdat - linkage. */ - { - comdat_linkage (decl); - DECL_INTERFACE_KNOWN (decl) = 1; - } #if 0 /* This clobbers the attrs stored in `decl' from `attrlist'. */ /* The decl and setting of decl_machine_attr is also turned off. */ @@ -11395,8 +11385,8 @@ build_enumerator (name, value) } tree -grok_enum_decls (type, decl) - tree type, decl; +grok_enum_decls (decl) + tree decl; { tree d = current_local_enum; @@ -11405,7 +11395,6 @@ grok_enum_decls (type, decl) while (1) { - TREE_TYPE (d) = type; if (TREE_CHAIN (d) == NULL_TREE) { TREE_CHAIN (d) = decl; @@ -11661,8 +11650,16 @@ start_function (declspecs, declarator, attrs, pre_parsed_p) if (DECL_INTERFACE_KNOWN (decl1)) { + tree ctx = hack_decl_function_context (decl1); + if (DECL_NOT_REALLY_EXTERN (decl1)) DECL_EXTERNAL (decl1) = 0; + + if (ctx != NULL_TREE && DECL_THIS_INLINE (ctx) + && TREE_PUBLIC (ctx)) + /* This is a function in a local class in an extern inline + function. */ + comdat_linkage (decl1); } /* If this function belongs to an interface, it is public. If it belongs to someone else's interface, it is also external. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index b003b6c2d12..253e8bf598c 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -916,7 +916,7 @@ grok_x_components (specs, components) break; } else if (TREE_CODE (t) == ENUMERAL_TYPE) - x = grok_enum_decls (t, NULL_TREE); + x = grok_enum_decls (NULL_TREE); else x = NULL_TREE; return x; @@ -929,13 +929,12 @@ grok_x_components (specs, components) } } else - { - t = TREE_TYPE (components); - if (TREE_CODE (t) == ENUMERAL_TYPE && TREE_NONLOCAL_FLAG (t)) - return grok_enum_decls (t, components); - else - return components; - } + /* There may or may not be any enum decls to grok, but + grok_enum_decls will just return components, if there aren't + any. We used to try to figure out whether or not there were + any enum decls based on the type of components, but that's too + hard; it might be something like `enum { a } *p;'. */ + return grok_enum_decls (components); } /* Classes overload their constituent function names automatically. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8782406c41c..a4c51dc7c36 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1401,7 +1401,7 @@ convert_nontype_argument (type, expr) --the name of an object or function with external linkage, including function templates and function template-ids but - excluding non- tatic class members, expressed as id-expression; + excluding non-static class members, expressed as id-expression; or --the address of an object or function with external linkage, @@ -1412,13 +1412,16 @@ convert_nontype_argument (type, expr) --a pointer to member expressed as described in _expr.unary.op_. */ + /* An integral constant-expression can include const variables + or enumerators. */ + if (INTEGRAL_TYPE_P (expr_type) && TREE_READONLY_DECL_P (expr)) + expr = decl_constant_value (expr); + if (INTEGRAL_TYPE_P (expr_type) || TYPE_PTRMEM_P (expr_type) || TYPE_PTRMEMFUNC_P (expr_type)) { - if (!TREE_CONSTANT (expr) - /* FIXME: Should this case be handled by fold()? Why not? */ - && !(TREE_CODE (expr) == VAR_DECL && TREE_READONLY (expr))) + if (! TREE_CONSTANT (expr)) { cp_error ("non-constant `%E' cannot be used as template argument", expr); @@ -5874,7 +5877,7 @@ tsubst_enum (tag, args, nargs, field_chain) finish_enum (newtag, values); if (NULL != field_chain) - *field_chain = grok_enum_decls (newtag, NULL_TREE); + *field_chain = grok_enum_decls (NULL_TREE); current_local_enum = prev_local_enum; -- 2.30.2