Hi,

On 01/29/2014 06:00 PM, Jason Merrill wrote:
On 01/29/2014 11:48 AM, Paolo Carlini wrote:
Rather than duplicate this code, let's factor it out into a separate
function.
Yeah, you are totally right, we have at least 3/4 uses of that. Care to
propose a name?
is_cxx_auto?
Good. I'm finishing testing the attached.

By the way, when I said 3/4 uses (in fact, at least 4 in the file), I meant the pattern:

        tree name = TYPE_NAME (type);
        if (TREE_CODE (name) == TYPE_DECL)
          name = DECL_NAME (name);

which I noticed yesterday. Could be a new macro? (post 4.9 maybe)

Thanks,
Paolo.

///////////////////
2014-01-29  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58561
        * dwarf2out.c (is_cxx_auto): New.
        (is_base_type): Use it.
        (gen_type_die_with_usage): Likewise.

/testsuite
2014-01-29  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58561
        * g++.dg/cpp1y/auto-fn23.C: New.
Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 207273)
+++ dwarf2out.c (working copy)
@@ -10219,6 +10219,23 @@ base_type_die (tree type)
   return base_type_result;
 }
 
+/* A C++ function with deduced return type can have a TEMPLATE_TYPE_PARM
+   named 'auto' in its type: return true for it, false otherwise.  */
+
+static inline bool
+is_cxx_auto (tree type)
+{
+  if (is_cxx ())
+    {
+      tree name = TYPE_NAME (type);
+      if (TREE_CODE (name) == TYPE_DECL)
+       name = DECL_NAME (name);
+      if (name == get_identifier ("auto"))
+       return true;
+    }
+  return false;
+}
+
 /* Given a pointer to an arbitrary ..._TYPE tree node, return nonzero if the
    given input type is a Dwarf "fundamental" type.  Otherwise return null.  */
 
@@ -10252,6 +10269,8 @@ is_base_type (tree type)
       return 0;
 
     default:
+      if (is_cxx_auto (type))
+       return 0;
       gcc_unreachable ();
     }
 
@@ -19830,24 +19849,16 @@ gen_type_die_with_usage (tree type, dw_die_ref con
       break;
 
     default:
-      // A C++ function with deduced return type can have
-      // a TEMPLATE_TYPE_PARM named 'auto' in its type.
-      if (is_cxx ())
+      if (is_cxx_auto (type))
        {
-         tree name = TYPE_NAME (type);
-         if (TREE_CODE (name) == TYPE_DECL)
-           name = DECL_NAME (name);
-         if (name == get_identifier ("auto"))
+         if (!auto_die)
            {
-             if (!auto_die)
-               {
-                 auto_die = new_die (DW_TAG_unspecified_type,
-                                     comp_unit_die (), NULL_TREE);
-                 add_name_attribute (auto_die, "auto");
-               }
-             equate_type_number_to_die (type, auto_die);
-             break;
+             auto_die = new_die (DW_TAG_unspecified_type,
+                                 comp_unit_die (), NULL_TREE);
+             add_name_attribute (auto_die, "auto");
            }
+         equate_type_number_to_die (type, auto_die);
+         break;
        }
       gcc_unreachable ();
     }
Index: testsuite/g++.dg/cpp1y/auto-fn23.C
===================================================================
--- testsuite/g++.dg/cpp1y/auto-fn23.C  (revision 0)
+++ testsuite/g++.dg/cpp1y/auto-fn23.C  (working copy)
@@ -0,0 +1,9 @@
+// PR c++/58561
+// { dg-options "-std=c++1y -g" }
+
+auto foo();
+
+namespace N
+{
+  using ::foo;
+}

Reply via email to