class.c (finish_struct): Use OVL_P.
authorNathan Sidwell <nathan@acm.org>
Thu, 29 Jun 2017 14:28:24 +0000 (14:28 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Thu, 29 Jun 2017 14:28:24 +0000 (14:28 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/cxx-pretty-print.c
gcc/cp/decl.c

index ece47f9..b91a6e0 100644 (file)
@@ -1,5 +1,14 @@
 2017-06-29  Nathan Sidwell  <nathan@acm.org>
 
+       * 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.
 
index 78cb5c2..2caf6fc 100644 (file)
@@ -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);
 }
 
index 6b175a3..6717bcb 100644 (file)
@@ -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)      \
index 5398e3d..edaee04 100644 (file)
@@ -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:
index 38c0348..c6b1f07 100644 (file)
@@ -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).  */