diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-08-23 19:43:38 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-08-23 19:43:38 +0000 |
commit | 3928bd5fc16719d56d6f99514148d4b05fcb9cc0 (patch) | |
tree | b151354daeecc119e542e5fed89789a62d400f91 | |
parent | 25d203fbadc0302b8bbdf948a46ba84cee1db335 (diff) | |
download | gcc-3928bd5fc16719d56d6f99514148d4b05fcb9cc0.zip gcc-3928bd5fc16719d56d6f99514148d4b05fcb9cc0.tar.gz gcc-3928bd5fc16719d56d6f99514148d4b05fcb9cc0.tar.bz2 |
semantics.c (finish_member_declaration): Move USING_DECL check earlier.
* semantics.c (finish_member_declaration): Move USING_DECL check
earlier. Always set C++ linkage. Commonize TYPE_FIELD and
template decl list insertion.
From-SVN: r251317
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 63 |
2 files changed, 27 insertions, 40 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3bc7de0..94c55ed 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-08-23 Nathan Sidwell <nathan@acm.org> + * semantics.c (finish_member_declaration): Move USING_DECL check + earlier. Always set C++ linkage. Commonize TYPE_FIELD and + template decl list insertion. + * cp-tree.h (maybe_version_functions): Declare. * decl.c (decls_match): Break function versioning check to separate function. Call it. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5401e78..14e680f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3025,7 +3025,13 @@ finish_member_declaration (tree decl) if (TREE_CODE (decl) != CONST_DECL) DECL_CONTEXT (decl) = current_class_type; - /* Check for bare parameter packs in the member variable declaration. */ + if (TREE_CODE (decl) == USING_DECL) + /* For now, ignore class-scope USING_DECLS, so that debugging + backends do not see them. */ + DECL_IGNORED_P (decl) = 1; + + /* Check for bare parameter packs in the non-static data member + declaration. */ if (TREE_CODE (decl) == FIELD_DECL) { if (check_for_bare_parameter_packs (TREE_TYPE (decl))) @@ -3038,54 +3044,31 @@ finish_member_declaration (tree decl) A C language linkage is ignored for the names of class members and the member function type of class member functions. */ - if (DECL_LANG_SPECIFIC (decl) && DECL_LANGUAGE (decl) == lang_c) + if (DECL_LANG_SPECIFIC (decl)) SET_DECL_LANGUAGE (decl, lang_cplusplus); - /* Put the decl on the TYPE_FIELDS list. Note that this is built up - in reverse order. We reverse it (to obtain declaration order) in - finish_struct. */ - if (DECL_DECLARES_FUNCTION_P (decl)) - { - /* We also need to add this function to the - CLASSTYPE_METHOD_VEC. */ - if (add_method (current_class_type, decl, false)) - { - gcc_assert (TYPE_MAIN_VARIANT (current_class_type) == current_class_type); - DECL_CHAIN (decl) = TYPE_FIELDS (current_class_type); - TYPE_FIELDS (current_class_type) = decl; + bool add = false; - maybe_add_class_template_decl_list (current_class_type, decl, - /*friend_p=*/0); - } - } + /* Functions and non-functions are added differently. */ + if (DECL_DECLARES_FUNCTION_P (decl)) + add = add_method (current_class_type, decl, false); /* Enter the DECL into the scope of the class, if the class isn't a closure (whose fields are supposed to be unnamed). */ else if (CLASSTYPE_LAMBDA_EXPR (current_class_type) || pushdecl_class_level (decl)) - { - if (TREE_CODE (decl) == USING_DECL) - { - /* For now, ignore class-scope USING_DECLS, so that - debugging backends do not see them. */ - DECL_IGNORED_P (decl) = 1; - } + add = true; + if (add) + { /* All TYPE_DECLs go at the end of TYPE_FIELDS. Ordinary fields - go at the beginning. The reason is that lookup_field_1 - searches the list in order, and we want a field name to - override a type name so that the "struct stat hack" will - work. In particular: - - struct S { enum E { }; int E } s; - s.E = 3; - - is valid. In addition, the FIELD_DECLs must be maintained in - declaration order so that class layout works as expected. - However, we don't need that order until class layout, so we - save a little time by putting FIELD_DECLs on in reverse order - here, and then reversing them in finish_struct_1. (We could - also keep a pointer to the correct insertion points in the - list.) */ + go at the beginning. The reason is that + legacy_nonfn_member_lookup searches the list in order, and we + want a field name to override a type name so that the "struct + stat hack" will work. In particular: + + struct S { enum E { }; static const int E = 5; int ary[S::E]; } s; + + is valid. */ if (TREE_CODE (decl) == TYPE_DECL) TYPE_FIELDS (current_class_type) |