]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/60314 ([C++1y] ICE with decltype(auto) when generating debug information)
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 28 Feb 2014 16:51:21 +0000 (16:51 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 28 Feb 2014 16:51:21 +0000 (16:51 +0000)
2014-02-25  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/60314
* dwarf2out.c (is_cxx_auto): Handle decltype(auto).

/testsuite
2014-02-25  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/60314
* g++.dg/cpp1y/auto-fn24.C: New.

From-SVN: r208225

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/auto-fn24.C [new file with mode: 0644]

index 70af44a4991165936362a7b25c522544acb36a68..87e4bb3e884874d65ab25cf801f2d46226703cdb 100644 (file)
@@ -1,3 +1,11 @@
+2014-02-28  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/60314
+       * dwarf2out.c (decltype_auto_die): New static.
+       (gen_subprogram_die): Handle 'decltype(auto)' like 'auto'.
+       (gen_type_die_with_usage): Handle 'decltype(auto)'.
+       (is_cxx_auto): Likewise.
+
 2014-02-28  Ian Bolton  <ian.bolton@arm.com>
 
        * config/aarch64/aarch64.h: Define __ARM_NEON by default if
index e202fa7357fbee218aac135e46aeb54a5a64198a..1c3ff03efe5cecd90ad349fa078a687f99446f71 100644 (file)
@@ -250,6 +250,9 @@ static GTY(()) section *cold_text_section;
 /* The DIE for C++1y 'auto' in a function return type.  */
 static GTY(()) dw_die_ref auto_die;
 
+/* The DIE for C++1y 'decltype(auto)' in a function return type.  */
+static GTY(()) dw_die_ref decltype_auto_die;
+
 /* Forward declarations for functions defined in this file.  */
 
 static char *stripattributes (const char *);
@@ -10230,7 +10233,8 @@ is_cxx_auto (tree type)
       tree name = TYPE_NAME (type);
       if (TREE_CODE (name) == TYPE_DECL)
        name = DECL_NAME (name);
-      if (name == get_identifier ("auto"))
+      if (name == get_identifier ("auto")
+         || name == get_identifier ("decltype(auto)"))
        return true;
     }
   return false;
@@ -18022,10 +18026,11 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
          if (get_AT_unsigned (old_die, DW_AT_decl_line) != (unsigned) s.line)
            add_AT_unsigned (subr_die, DW_AT_decl_line, s.line);
 
-         /* If the prototype had an 'auto' return type, emit the real
-            type on the definition die.  */
+         /* If the prototype had an 'auto' or 'decltype(auto)' return type,
+            emit the real type on the definition die.  */
          if (is_cxx() && debug_info_level > DINFO_LEVEL_TERSE
-             && get_AT_ref (old_die, DW_AT_type) == auto_die)
+             && (get_AT_ref (old_die, DW_AT_type) == auto_die
+                 || get_AT_ref (old_die, DW_AT_type) == decltype_auto_die))
            add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)),
                                0, 0, context_die);
        }
@@ -19852,13 +19857,18 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
     default:
       if (is_cxx_auto (type))
        {
-         if (!auto_die)
+         tree name = TYPE_NAME (type);
+         if (TREE_CODE (name) == TYPE_DECL)
+           name = DECL_NAME (name);
+         dw_die_ref *die = (name == get_identifier ("auto")
+                            ? &auto_die : &decltype_auto_die);
+         if (!*die)
            {
-             auto_die = new_die (DW_TAG_unspecified_type,
-                                 comp_unit_die (), NULL_TREE);
-             add_name_attribute (auto_die, "auto");
+             *die = new_die (DW_TAG_unspecified_type,
+                             comp_unit_die (), NULL_TREE);
+             add_name_attribute (*die, IDENTIFIER_POINTER (name));
            }
-         equate_type_number_to_die (type, auto_die);
+         equate_type_number_to_die (type, *die);
          break;
        }
       gcc_unreachable ();
index dac918c89ae6bcfa1658ddee5a696985a244687a..c8a7fb4f094e0843d74660dad2f88a354747386b 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-28  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/60314
+       * g++.dg/cpp1y/auto-fn24.C: New.
+
 2014-02-28  Joey Ye  <joey.ye@arm.com>
 
        PR target/PR60169
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn24.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn24.C
new file mode 100644 (file)
index 0000000..8808575
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/60314
+// { dg-options "-std=c++1y -g" }
+
+// fine
+decltype(auto) qux() { return 42; }
+
+struct foo
+{
+  // also ICEs if not static 
+  static decltype(auto) bar()
+  { return 42; }
+};