From: Nathan Sidwell Date: Thu, 29 Jun 2017 14:28:24 +0000 (+0000) Subject: class.c (finish_struct): Use OVL_P. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=79a2e690b4654e88437aa40627f24068dc5216f5;p=gcc.git class.c (finish_struct): Use OVL_P. * class.c (finish_struct): Use OVL_P. (get_vfield_name): Measure constructor_name length. * cp-tree.h (SET_CLASS_TYPE_P): Add RECORD_OR_UNION_CHECK. (NON_UNION_CLASS_TYPE_P): Check RECORD_TYPE up front. * cxx-pretty-print.c (is_destructor_name): Delete. (pp_cxx_unqualified_id): Remove bogus destructor name checking. * decl.c (grokfndecl): Move cheap checks first when looking for implicit extern cness. From-SVN: r249788 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ece47f9de12..b91a6e072ae 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,14 @@ 2017-06-29 Nathan Sidwell + * class.c (finish_struct): Use OVL_P. + (get_vfield_name): Measure constructor_name length. + * cp-tree.h (SET_CLASS_TYPE_P): Add RECORD_OR_UNION_CHECK. + (NON_UNION_CLASS_TYPE_P): Check RECORD_TYPE up front. + * cxx-pretty-print.c (is_destructor_name): Delete. + (pp_cxx_unqualified_id): Remove bogus destructor name checking. + * decl.c (grokfndecl): Move cheap checks first when looking for + implicit extern cness. + * parser.c (cp_parser_direct_declarator): Reorder if to avoid indentation. Remove unnecessary assignment of constructor name. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 78cb5c2e81d..2caf6fc374b 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -7443,7 +7443,7 @@ finish_struct (tree t, tree attributes) if (TREE_CODE (x) == USING_DECL) { tree fn = strip_using_decl (x); - if (is_overloaded_fn (fn)) + if (OVL_P (fn)) for (lkp_iterator iter (fn); iter; ++iter) add_method (t, *iter, true); } @@ -8504,7 +8504,6 @@ static tree get_vfield_name (tree type) { tree binfo, base_binfo; - char *buf; for (binfo = TYPE_BINFO (type); BINFO_N_BASE_BINFOS (binfo); @@ -8518,10 +8517,10 @@ get_vfield_name (tree type) } type = BINFO_TYPE (binfo); - buf = (char *) alloca (sizeof (VFIELD_NAME_FORMAT) - + TYPE_NAME_LENGTH (type) + 2); - sprintf (buf, VFIELD_NAME_FORMAT, - IDENTIFIER_POINTER (constructor_name (type))); + tree ctor_name = constructor_name (type); + char *buf = (char *) alloca (sizeof (VFIELD_NAME_FORMAT) + + IDENTIFIER_LENGTH (ctor_name) + 2); + sprintf (buf, VFIELD_NAME_FORMAT, IDENTIFIER_POINTER (ctor_name)); return get_identifier (buf); } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 6b175a31466..6717bcb1a27 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1814,7 +1814,7 @@ enum languages { lang_c, lang_cplusplus }; /* Set CLASS_TYPE_P for T to VAL. T must be a class, struct, or union type. */ #define SET_CLASS_TYPE_P(T, VAL) \ - (TYPE_LANG_FLAG_5 (T) = (VAL)) + (TYPE_LANG_FLAG_5 (RECORD_OR_UNION_CHECK (T)) = (VAL)) /* Nonzero if T is a class type. Zero for template type parameters, typename types, and so forth. */ @@ -1823,7 +1823,7 @@ enum languages { lang_c, lang_cplusplus }; /* Nonzero if T is a class type but not an union. */ #define NON_UNION_CLASS_TYPE_P(T) \ - (CLASS_TYPE_P (T) && TREE_CODE (T) != UNION_TYPE) + (TREE_CODE (T) == RECORD_TYPE && TYPE_LANG_FLAG_5 (T)) /* Keep these checks in ascending code order. */ #define RECORD_OR_UNION_CODE_P(T) \ diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 5398e3dd87d..edaee04d7fb 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -88,14 +88,6 @@ pp_cxx_separate_with (cxx_pretty_printer *pp, int c) /* Expressions. */ -static inline bool -is_destructor_name (tree name) -{ - return name == complete_dtor_identifier - || name == base_dtor_identifier - || name == deleting_dtor_identifier; -} - /* conversion-function-id: operator conversion-type-id @@ -162,16 +154,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t) else if (IDENTIFIER_CONV_OP_P (t)) pp_cxx_conversion_function_id (pp, t); else - { - if (is_destructor_name (t)) - { - pp_complement (pp); - /* FIXME: Why is this necessary? */ - if (TREE_TYPE (t)) - t = constructor_name (TREE_TYPE (t)); - } - pp_cxx_tree_identifier (pp, t); - } + pp_cxx_tree_identifier (pp, t); break; case TEMPLATE_ID_EXPR: diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 38c0348bc89..c6b1f07eeef 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8580,16 +8580,18 @@ grokfndecl (tree ctype, DECL_CONTEXT (decl) = FROB_CONTEXT (current_decl_namespace ()); /* `main' and builtins have implicit 'C' linkage. */ - if ((MAIN_NAME_P (declarator) - || (IDENTIFIER_LENGTH (declarator) > 10 - && IDENTIFIER_POINTER (declarator)[0] == '_' - && IDENTIFIER_POINTER (declarator)[1] == '_' - && strncmp (IDENTIFIER_POINTER (declarator)+2, "builtin_", 8) == 0) - || (targetcm.cxx_implicit_extern_c - && targetcm.cxx_implicit_extern_c(IDENTIFIER_POINTER (declarator)))) + if (ctype == NULL_TREE + && DECL_FILE_SCOPE_P (decl) && current_lang_name == lang_name_cplusplus - && ctype == NULL_TREE - && DECL_FILE_SCOPE_P (decl)) + && (MAIN_NAME_P (declarator) + || (IDENTIFIER_LENGTH (declarator) > 10 + && IDENTIFIER_POINTER (declarator)[0] == '_' + && IDENTIFIER_POINTER (declarator)[1] == '_' + && strncmp (IDENTIFIER_POINTER (declarator)+2, + "builtin_", 8) == 0) + || (targetcm.cxx_implicit_extern_c + && (targetcm.cxx_implicit_extern_c + (IDENTIFIER_POINTER (declarator)))))) SET_DECL_LANGUAGE (decl, lang_c); /* Should probably propagate const out from type to decl I bet (mrs). */