[PATCH 2/2] DWARF5: Add DW_TAG_aligned_type support.

2014-07-09 Thread Mark Wielaard
gcc/ChangeLog

* dwarf2out.c (decl_user_align): New function.
(type_user_align): Likewise.
(modified_type_die): Add and handle align argument.
(add_bound_info): Likewise.
(base_type_for_mode): Call modified_type_die with zero user align.
(add_subscript_info): Call add_type_attribute with zero user align.
(gen_array_type_die): Likewise.
(gen_descr_array_type_die): Likewise.
(gen_entry_point_die): Likewise.
(gen_enumeration_type_die): Likewise.
(gen_formal_parameter_die): Likewise.
(gen_subprogram_die): Likewise.
(gen_variable_die): Likewise.
(gen_const_die): Likewise.
(gen_field_die): Likewise.
(gen_pointer_type_die): Likewise.
(gen_reference_type_die): Likewise.
(gen_ptr_to_mbr_type_die): Likewise.
(gen_inheritance_die): Likewise.
(gen_subroutine_type_die): Likewise.
(gen_typedef_die): Likewise.
(force_type_die): Likewise.

gcc/testsuite/ChangeLog

* gcc.dg/guality/alignas.c: New test.
---
 gcc/ChangeLog  |   25 +++
 gcc/dwarf2out.c|  116 ++--
 gcc/testsuite/ChangeLog|4 +
 gcc/testsuite/gcc.dg/guality/alignas.c |   57 
 include/dwarf2.def |3 +
 5 files changed, 168 insertions(+), 37 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/guality/alignas.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7550064..186fba5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,30 @@
 2014-07-09  Mark Wielaard  
 
+   * dwarf2out.c (decl_user_align): New function.
+   (type_user_align): Likewise.
+   (modified_type_die): Add and handle align argument.
+   (add_bound_info): Likewise.
+   (base_type_for_mode): Call modified_type_die with zero user align.
+   (add_subscript_info): Call add_type_attribute with zero user align.
+   (gen_array_type_die): Likewise.
+   (gen_descr_array_type_die): Likewise.
+   (gen_entry_point_die): Likewise.
+   (gen_enumeration_type_die): Likewise.
+   (gen_formal_parameter_die): Likewise.
+   (gen_subprogram_die): Likewise.
+   (gen_variable_die): Likewise.
+   (gen_const_die): Likewise.
+   (gen_field_die): Likewise.
+   (gen_pointer_type_die): Likewise.
+   (gen_reference_type_die): Likewise.
+   (gen_ptr_to_mbr_type_die): Likewise.
+   (gen_inheritance_die): Likewise.
+   (gen_subroutine_type_die): Likewise.
+   (gen_typedef_die): Likewise.
+   (force_type_die): Likewise.
+
+2014-07-09  Mark Wielaard  
+
PR debug/60782
* dwarf2out.c (modified_type_die): Handle TYPE_QUAL_ATOMIC.
* opts.c (common_handle_option): Accept -gdwarf-5.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index c4649c3..cd7d782 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -3141,7 +3141,7 @@ static dw_die_ref base_type_die (tree);
 static int is_base_type (tree);
 static dw_die_ref subrange_type_die (tree, tree, tree, dw_die_ref);
 static int decl_quals (const_tree);
-static dw_die_ref modified_type_die (tree, int, dw_die_ref);
+static dw_die_ref modified_type_die (tree, int, unsigned int, dw_die_ref);
 static dw_die_ref generic_parameter_die (tree, tree, bool, dw_die_ref);
 static dw_die_ref template_parameter_pack_die (tree, tree, dw_die_ref);
 static int type_is_enum (const_tree);
@@ -3199,7 +3199,7 @@ static dw_die_ref scope_die_for (tree, dw_die_ref);
 static inline int local_scope_p (dw_die_ref);
 static inline int class_scope_p (dw_die_ref);
 static inline int class_or_namespace_scope_p (dw_die_ref);
-static void add_type_attribute (dw_die_ref, tree, int, dw_die_ref);
+static void add_type_attribute (dw_die_ref, tree, int, unsigned int, 
dw_die_ref);
 static void add_calling_convention_attribute (dw_die_ref, tree);
 static const char *type_tag (const_tree);
 static tree member_declared_type (const_tree);
@@ -10504,11 +10504,30 @@ decl_quals (const_tree decl)
 ? TYPE_QUAL_VOLATILE : TYPE_UNQUALIFIED));
 }
 
+static unsigned int
+decl_user_align (const_tree decl)
+{
+  if (DECL_USER_ALIGN (decl))
+return DECL_ALIGN_UNIT (decl);
+
+  return 0;
+}
+
+static unsigned int
+type_user_align (const_tree type)
+{
+  if (TYPE_USER_ALIGN (type))
+return TYPE_ALIGN_UNIT (type);
+
+  return 0;
+}
+
 /* Given a pointer to an arbitrary ..._TYPE tree node, return a debugging
entry that chains various modifiers in front of the given type.  */
 
 static dw_die_ref
-modified_type_die (tree type, int cv_quals, dw_die_ref context_die)
+modified_type_die (tree type, int cv_quals, unsigned int align,
+  dw_die_ref context_die)
 {
   enum tree_code code = TREE_CODE (type);
   dw_die_ref mod_type_die;
@@ -10531,14 +10550,23 @@ modified_type_die (tree type, int cv_quals, 
dw_die_ref context_die)
   if (dwarf_version < 3)
 cv_quals &= ~TYPE_QUAL_RES

[PATCH 2/2] DWARF5: Add DW_TAG_aligned_type support.

2014-08-12 Thread Mark Wielaard
Ping. As with the patch for DW_TAG_atomic_type this is only experimental
at this time, but feedback appreciated.

There is a corresponding patch for GDB:
https://sourceware.org/ml/gdb-patches/2014-07/msg00199.html

gcc/ChangeLog

* dwarf2out.c (decl_user_align): New function.
(type_user_align): Likewise.
(modified_type_die): Add and handle align argument.
(add_bound_info): Likewise.
(base_type_for_mode): Call modified_type_die with zero user align.
(add_subscript_info): Call add_type_attribute with zero user align.
(gen_array_type_die): Likewise.
(gen_descr_array_type_die): Likewise.
(gen_entry_point_die): Likewise.
(gen_enumeration_type_die): Likewise.
(gen_formal_parameter_die): Likewise.
(gen_subprogram_die): Likewise.
(gen_variable_die): Likewise.
(gen_const_die): Likewise.
(gen_field_die): Likewise.
(gen_pointer_type_die): Likewise.
(gen_reference_type_die): Likewise.
(gen_ptr_to_mbr_type_die): Likewise.
(gen_inheritance_die): Likewise.
(gen_subroutine_type_die): Likewise.
(gen_typedef_die): Likewise.
(force_type_die): Likewise.

gcc/testsuite/ChangeLog

* gcc.dg/guality/alignas.c: New test.
---
 gcc/ChangeLog  |  25 +++
 gcc/dwarf2out.c| 116 ++---
 gcc/testsuite/ChangeLog|   4 ++
 gcc/testsuite/gcc.dg/guality/alignas.c |  57 
 include/dwarf2.def |   3 +
 5 files changed, 168 insertions(+), 37 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/guality/alignas.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1adf6a6..ba37472 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,30 @@
 2014-07-09  Mark Wielaard  
 
+   * dwarf2out.c (decl_user_align): New function.
+   (type_user_align): Likewise.
+   (modified_type_die): Add and handle align argument.
+   (add_bound_info): Likewise.
+   (base_type_for_mode): Call modified_type_die with zero user align.
+   (add_subscript_info): Call add_type_attribute with zero user align.
+   (gen_array_type_die): Likewise.
+   (gen_descr_array_type_die): Likewise.
+   (gen_entry_point_die): Likewise.
+   (gen_enumeration_type_die): Likewise.
+   (gen_formal_parameter_die): Likewise.
+   (gen_subprogram_die): Likewise.
+   (gen_variable_die): Likewise.
+   (gen_const_die): Likewise.
+   (gen_field_die): Likewise.
+   (gen_pointer_type_die): Likewise.
+   (gen_reference_type_die): Likewise.
+   (gen_ptr_to_mbr_type_die): Likewise.
+   (gen_inheritance_die): Likewise.
+   (gen_subroutine_type_die): Likewise.
+   (gen_typedef_die): Likewise.
+   (force_type_die): Likewise.
+
+2014-07-09  Mark Wielaard  
+
PR debug/60782
* dwarf2out.c (modified_type_die): Handle TYPE_QUAL_ATOMIC.
* opts.c (common_handle_option): Accept -gdwarf-5.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 7792604..c3f1d80 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -3142,7 +3142,7 @@ static dw_die_ref base_type_die (tree);
 static int is_base_type (tree);
 static dw_die_ref subrange_type_die (tree, tree, tree, dw_die_ref);
 static int decl_quals (const_tree);
-static dw_die_ref modified_type_die (tree, int, dw_die_ref);
+static dw_die_ref modified_type_die (tree, int, unsigned int, dw_die_ref);
 static dw_die_ref generic_parameter_die (tree, tree, bool, dw_die_ref);
 static dw_die_ref template_parameter_pack_die (tree, tree, dw_die_ref);
 static int type_is_enum (const_tree);
@@ -3200,7 +3200,7 @@ static dw_die_ref scope_die_for (tree, dw_die_ref);
 static inline int local_scope_p (dw_die_ref);
 static inline int class_scope_p (dw_die_ref);
 static inline int class_or_namespace_scope_p (dw_die_ref);
-static void add_type_attribute (dw_die_ref, tree, int, dw_die_ref);
+static void add_type_attribute (dw_die_ref, tree, int, unsigned int, 
dw_die_ref);
 static void add_calling_convention_attribute (dw_die_ref, tree);
 static const char *type_tag (const_tree);
 static tree member_declared_type (const_tree);
@@ -10460,11 +10460,30 @@ decl_quals (const_tree decl)
 ? TYPE_QUAL_VOLATILE : TYPE_UNQUALIFIED));
 }
 
+static unsigned int
+decl_user_align (const_tree decl)
+{
+  if (DECL_USER_ALIGN (decl))
+return DECL_ALIGN_UNIT (decl);
+
+  return 0;
+}
+
+static unsigned int
+type_user_align (const_tree type)
+{
+  if (TYPE_USER_ALIGN (type))
+return TYPE_ALIGN_UNIT (type);
+
+  return 0;
+}
+
 /* Given a pointer to an arbitrary ..._TYPE tree node, return a debugging
entry that chains various modifiers in front of the given type.  */
 
 static dw_die_ref
-modified_type_die (tree type, int cv_quals, dw_die_ref context_die)
+modified_type_die (tree type, int cv_quals, unsigned int align,
+  dw_die_ref context_die)
 {
   enum tre

Re: [PATCH 2/2] DWARF5: Add DW_TAG_aligned_type support.

2014-08-12 Thread Jason Merrill
I'm dubious about adding a tag for alignment, because it doesn't 
participate in the type system; in C and C++, it's an attribute of a 
struct or variable declaration, but the variable has the same type as 
another variable without the explicit alignment.  In the GNU extension 
it can also be applied to a typedef, but I think there I'd still put the 
attribute on the typedef rather than introduce a new tag.


Jason