Re: [C++ Patch] PR 60314 (ICE with decltype(auto))

2014-03-01 Thread Jason Merrill

OK.

Jason


Re: [C++ Patch] PR 60314 (ICE with decltype(auto))

2014-03-01 Thread Paolo Carlini

Hi,

On 02/28/2014 04:50 PM, Jason Merrill wrote:

OK, thanks.
Applied. I have just noticed (sorry) that get_AT_ref (thus get_AT) isn't 
trivial at all, thus I propose to apply the below. Is it Ok with you?


Thanks,
Paolo.

//
2014-03-01  Paolo Carlini  

* dwarf2out.c (gen_subprogram_die): Tidy.
Index: dwarf2out.c
===
--- dwarf2out.c (revision 208243)
+++ dwarf2out.c (working copy)
@@ -18028,11 +18028,13 @@ gen_subprogram_die (tree decl, dw_die_ref context_
 
  /* 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) == decltype_auto_die))
-   add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)),
-   0, 0, context_die);
+ if (is_cxx() && debug_info_level > DINFO_LEVEL_TERSE)
+   {
+ dw_die_ref die = get_AT_ref (old_die, DW_AT_type);
+ if (die == auto_die || die == decltype_auto_die)
+   add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)),
+   0, 0, context_die);
+   }
}
 }
   else


Re: [C++ Patch] PR 60314 (ICE with decltype(auto))

2014-02-28 Thread Jason Merrill

OK, thanks.

Jason


Re: [C++ Patch] PR 60314 (ICE with decltype(auto))

2014-02-28 Thread Paolo Carlini

Hi,

On 02/27/2014 08:29 PM, Jason Merrill wrote:

On 02/25/2014 05:03 AM, Paolo Carlini wrote:

here we ICE exactly as we did in c++/53756: the only difference is the
use of decltype(auto) instead of auto. Now, if we compare is_cxx_auto to
is_auto (the front-end helper), evidently there is an inconsistency
about the handling of decltype(auto) and the below fixes the ICE.
However, also clearly the patchlet needs a review, because an out of
class decltype(auto) is already fine. Also, I'm not 100% sure we don't
need a decltype_auto_die, etc.


I think we do need a decltype_auto_die.


Ok, then I tested on x86_64-linux the below.

Thanks!
Paolo.

///
2014-02-28  Paolo Carlini  

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.

/testsuite
2014-02-28  Paolo Carlini  

PR c++/60314
* g++.dg/cpp1y/auto-fn24.C: New.
Index: dwarf2out.c
===
--- dwarf2out.c (revision 208214)
+++ dwarf2out.c (working copy)
@@ -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_
  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 con
 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: testsuite/g++.dg/cpp1y/auto-fn24.C
===
--- testsuite/g++.dg/cpp1y/auto-fn24.C  (revision 0)
+++ testsuite/g++.dg/cpp1y/auto-fn24.C  (working copy)
@@ -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; }
+};


Re: [C++ Patch] PR 60314 (ICE with decltype(auto))

2014-02-27 Thread Jason Merrill

On 02/25/2014 05:03 AM, Paolo Carlini wrote:

here we ICE exactly as we did in c++/53756: the only difference is the
use of decltype(auto) instead of auto. Now, if we compare is_cxx_auto to
is_auto (the front-end helper), evidently there is an inconsistency
about the handling of decltype(auto) and the below fixes the ICE.
However, also clearly the patchlet needs a review, because an out of
class decltype(auto) is already fine. Also, I'm not 100% sure we don't
need a decltype_auto_die, etc.


I think we do need a decltype_auto_die.

Jason



[C++ Patch] PR 60314 (ICE with decltype(auto))

2014-02-25 Thread Paolo Carlini

Hi,

here we ICE exactly as we did in c++/53756: the only difference is the 
use of decltype(auto) instead of auto. Now, if we compare is_cxx_auto to 
is_auto (the front-end helper), evidently there is an inconsistency 
about the handling of decltype(auto) and the below fixes the ICE. 
However, also clearly the patchlet needs a review, because an out of 
class decltype(auto) is already fine. Also, I'm not 100% sure we don't 
need a decltype_auto_die, etc.


Tested x86_64-linux.

Thanks,
Paolo.

///
2014-02-25  Paolo Carlini  

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

/testsuite
2014-02-25  Paolo Carlini  

PR c++/60314
* g++.dg/cpp1y/auto-fn24.C: New.
Index: dwarf2out.c
===
--- dwarf2out.c (revision 208113)
+++ dwarf2out.c (working copy)
@@ -10230,7 +10230,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;
Index: testsuite/g++.dg/cpp1y/auto-fn24.C
===
--- testsuite/g++.dg/cpp1y/auto-fn24.C  (revision 0)
+++ testsuite/g++.dg/cpp1y/auto-fn24.C  (working copy)
@@ -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; }
+};