Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-21 Thread Mark Wielaard
On Tue, 2014-05-20 at 15:46 -0400, Jason Merrill wrote:
 Rather than define the hook for C, let's have a default version that 
 uses the type_for_size langhook; that should work better for Ada.

That also makes the patch simpler. Updated patch attached.

Bootstrapped on x86_64-unknown-linux-gnu with --enable-languages=c,c
++,objc,java,ada,fortran and ran against the gdb testsuite without
regressions (there is a tweak needed for one test regexp in
gdb.cp/var-tag.exp to deal with the extra type information, but Tom and
I already discussed on irc this isn't a regression, I'll submit a gdb
testsuite patch asap).

Thanks,

Mark
From 6b3fbed4b2bfda22c6e55e151fbaef29c8208c39 Mon Sep 17 00:00:00 2001
From: Mark Wielaard m...@redhat.com
Date: Wed, 21 May 2014 13:00:30 +0200
Subject: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. The default implementation will just uses type_for_size.
The implementation for C++ will use the ENUM_UNDERLYING_TYPE if it exists.
Use this enum_underlying_base_type lang-hook in dwarf2out.c to add a
DW_AT_type base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if DWARF
	version = 3 or not strict DWARF.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks.c (lhd_enum_underlying_base_type): New function.
	* gcc/langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (lhd_enum_underlying_base_type): New declaration.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
---
 gcc/ChangeLog   |   14 ++
 gcc/cp/ChangeLog|6 ++
 gcc/cp/cp-lang.c|   18 ++
 gcc/dwarf2out.c |5 +
 gcc/langhooks-def.h |5 -
 gcc/langhooks.c |8 
 gcc/langhooks.h |2 ++
 7 files changed, 57 insertions(+), 1 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e2e3dd3..23f7296 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2014-05-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if DWARF
+	version = 3 or not strict DWARF.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks.c (lhd_enum_underlying_base_type): New function.
+	* gcc/langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (lhd_enum_underlying_base_type): New declaration.
+	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
 2014-05-21  Oleg Endo  olege...@gcc.gnu.org
 
 	PR target/54236
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 790b87e..085d0f5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2014-05-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* cp-lang.c (cxx_enum_underlying_base_type): New function.
+	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-05-21  Igor Zamyatin  igor.zamya...@intel.com
 
 	PR c/60189
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index c28c07a..6a40d29 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include coretypes.h
 #include tm.h
 #include tree.h
+#include stor-layout.h
 #include cp-tree.h
 #include c-family/c-common.h
 #include langhooks.h
@@ -40,6 +41,7 @@ static enum classify_record cp_classify_record (tree type);
 static tree cp_eh_personality (void);
 static tree get_template_innermost_arguments_folded (const_tree);
 static tree get_template_argument_pack_elems_folded (const_tree);
+static tree cxx_enum_underlying_base_type (const_tree);
 
 /* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h;
consequently, there should be very few hooks below.  */
@@ -81,6 +83,8 @@ static tree get_template_argument_pack_elems_folded (const_tree);
 #define LANG_HOOKS_EH_PERSONALITY cp_eh_personality
 #undef LANG_HOOKS_EH_RUNTIME_TYPE
 #define LANG_HOOKS_EH_RUNTIME_TYPE build_eh_type_type
+#undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE
+#define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE cxx_enum_underlying_base_type
 
 /* Each front end provides its own lang hook initializer.  */
 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
@@ -219,5 +223,19 @@ get_template_argument_pack_elems_folded (const_tree t)
   return fold_cplus_constants (get_template_argument_pack_elems (t));
 }
 
+/* The C++ version of the enum_underlying_base_type langhook.
+   See also cp/semantics.c (finish_underlying_type).  */
+static tree cxx_enum_underlying_base_type (const_tree type)
+{
+  tree underlying_type = ENUM_UNDERLYING_TYPE (type);
+
+  if (! ENUM_FIXED_UNDERLYING_TYPE_P (type

Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-21 Thread Jason Merrill

On 05/21/2014 09:27 AM, Mark Wielaard wrote:

+/* The C++ version of the enum_underlying_base_type langhook.
+   See also cp/semantics.c (finish_underlying_type).  */
+static tree cxx_enum_underlying_base_type (const_tree type)


We usually leave a blank line between the comment and the function. 
Also, the function name should be at the beginning of the line for etags.



+/* Default implementation of enum_underlying_base_type using type_for_size.  */
+tree
+lhd_enum_underlying_base_type (const_tree enum_type)


Blank line here, too.


   tree (*reconstruct_complex_type) (tree, tree);
+
+  tree (*enum_underlying_base_type) (const_tree);


And please add a comment documenting the hook.

OK with those changes.

Jason



Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-21 Thread Mark Wielaard
On Wed, 2014-05-21 at 10:33 -0400, Jason Merrill wrote:
 On 05/21/2014 09:27 AM, Mark Wielaard wrote:
  +/* The C++ version of the enum_underlying_base_type langhook.
  +   See also cp/semantics.c (finish_underlying_type).  */
  +static tree cxx_enum_underlying_base_type (const_tree type)
 
 We usually leave a blank line between the comment and the function. 
 Also, the function name should be at the beginning of the line for etags.

Fixed both issues.

  +/* Default implementation of enum_underlying_base_type using 
  type_for_size.  */
  +tree
  +lhd_enum_underlying_base_type (const_tree enum_type)
 
 Blank line here, too.

Added.

 tree (*reconstruct_complex_type) (tree, tree);
  +
  +  tree (*enum_underlying_base_type) (const_tree);
 
 And please add a comment documenting the hook.

Documentation added.

 OK with those changes.

Pushed as attached.

Thanks,

Mark
From 1b006e46754125c47544223aa6ee8a42d102fe4d Mon Sep 17 00:00:00 2001
From: mark mark@138bc75d-0d04-0410-961f-82ee72b054a4
Date: Wed, 21 May 2014 15:44:59 +
Subject: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. The default implementation will just use type_for_size.
The implementation for C++ will use the ENUM_UNDERLYING_TYPE if it exists.
Use this enum_underlying_base_type lang-hook in dwarf2out.c to add a
DW_AT_type base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if DWARF
	version = 3 or not strict DWARF.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks.c (lhd_enum_underlying_base_type): New function.
	* gcc/langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (lhd_enum_underlying_base_type): New declaration.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210717 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog   |   14 ++
 gcc/cp/ChangeLog|6 ++
 gcc/cp/cp-lang.c|   20 
 gcc/dwarf2out.c |5 +
 gcc/langhooks-def.h |5 -
 gcc/langhooks.c |9 +
 gcc/langhooks.h |6 ++
 7 files changed, 64 insertions(+), 1 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d506727..452b4b0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2014-05-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if DWARF
+	version = 3 or not strict DWARF.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks.c (lhd_enum_underlying_base_type): New function.
+	* gcc/langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (lhd_enum_underlying_base_type): New declaration.
+	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
 2014-05-21  Richard Biener  rguent...@suse.de
 
 	* doc/invoke.texi (-flto-partition=): Document one and
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index adde47f..b0a06b1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2014-05-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* cp-lang.c (cxx_enum_underlying_base_type): New function.
+	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-05-21  Richard Sandiford  rsand...@linux.vnet.ibm.com
 
 	* cvt.c (convert_to_void): Use void_node instead of void_zero_node.
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index c28c07a..014f393 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include coretypes.h
 #include tm.h
 #include tree.h
+#include stor-layout.h
 #include cp-tree.h
 #include c-family/c-common.h
 #include langhooks.h
@@ -40,6 +41,7 @@ static enum classify_record cp_classify_record (tree type);
 static tree cp_eh_personality (void);
 static tree get_template_innermost_arguments_folded (const_tree);
 static tree get_template_argument_pack_elems_folded (const_tree);
+static tree cxx_enum_underlying_base_type (const_tree);
 
 /* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h;
consequently, there should be very few hooks below.  */
@@ -81,6 +83,8 @@ static tree get_template_argument_pack_elems_folded (const_tree);
 #define LANG_HOOKS_EH_PERSONALITY cp_eh_personality
 #undef LANG_HOOKS_EH_RUNTIME_TYPE
 #define LANG_HOOKS_EH_RUNTIME_TYPE build_eh_type_type
+#undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE
+#define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE cxx_enum_underlying_base_type
 
 /* Each front end provides its own lang hook initializer.  */
 struct lang_hooks lang_hooks

Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-20 Thread Mark Wielaard
On Mon, May 19, 2014 at 04:50:35PM -0400, Jason Merrill wrote:
 On 05/13/2014 03:21 AM, Mark Wielaard wrote:
 So the debugger doesn't have to guess the properties of the enum's
 underlying base type, like size, encoding and signedness.
 
 Well, the enum already has DW_AT_byte_size.  It seems to me that it should
 also have DW_AT_encoding to provide the other two properties you mention.

Right, that is the idea, since an enum doesn't provide those attributes,
it should have a reference to the underlying base type that provides them.
Then it can also drop the DW_AT_byte_size, if it is different from the
underlying base type, but that is a followup patch.

Thanks,

Mark


Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-20 Thread Jason Merrill

On 05/20/2014 02:55 AM, Mark Wielaard wrote:

On Mon, May 19, 2014 at 04:50:35PM -0400, Jason Merrill wrote:

On 05/13/2014 03:21 AM, Mark Wielaard wrote:

So the debugger doesn't have to guess the properties of the enum's
underlying base type, like size, encoding and signedness.


Well, the enum already has DW_AT_byte_size.  It seems to me that it should
also have DW_AT_encoding to provide the other two properties you mention.


Right, that is the idea, since an enum doesn't provide those attributes,
it should have a reference to the underlying base type that provides them.


Yes, but why is that better than providing them directly?  The latter 
would seem to work better with non-C-family languages like Ada.


Jason



Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-20 Thread Mark Wielaard
On Tue, May 20, 2014 at 10:43:22AM -0400, Jason Merrill wrote:
 On 05/20/2014 02:55 AM, Mark Wielaard wrote:
 On Mon, May 19, 2014 at 04:50:35PM -0400, Jason Merrill wrote:
 On 05/13/2014 03:21 AM, Mark Wielaard wrote:
 So the debugger doesn't have to guess the properties of the enum's
 underlying base type, like size, encoding and signedness.
 
 Well, the enum already has DW_AT_byte_size.  It seems to me that it should
 also have DW_AT_encoding to provide the other two properties you mention.
 
 Right, that is the idea, since an enum doesn't provide those attributes,
 it should have a reference to the underlying base type that provides them.
 
 Yes, but why is that better than providing them directly?

Because that would loose the information of which underlying type
is used to implement the enum. And it is probably less efficient to
replicate all the attributes for each enum. It is also simply how the
DWARF standard specifies these properties. They are not attached to the
DW_TAG_enumeration_type directly but specified through the underlying
type. Which is what gdb expects now.

The DWARF part isn't what this patch is blocked on. That has already
been discussed on the DWARF standard list, coordinated with the gdb
hackers and approved some months ago. The part that hasn't been reviewed
and approved yet is the frontend changes that implement the lang-hook.

Thanks,

Mark


Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-20 Thread Jason Merrill

On 05/20/2014 01:51 PM, Mark Wielaard wrote:

The DWARF part isn't what this patch is blocked on. That has already
been discussed on the DWARF standard list, coordinated with the gdb
hackers and approved some months ago.


Fair enough.


The part that hasn't been reviewed
and approved yet is the frontend changes that implement the lang-hook.


Rather than define the hook for C, let's have a default version that 
uses the type_for_size langhook; that should work better for Ada.


Jason




Ping4: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-19 Thread Mark Wielaard
Rebased patch to current master attached. DWARF parts approved by
Cary Coutant, GDB already contains Tom Tromey's code to take advantage
of the new information. Earlier discussions:
https://gcc.gnu.org/ml/gcc-patches/2014-04/msg00713.html
https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01859.html
https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00922.html
If there are any unanswered questions that might help getting this
reviewed, please let me know.
commit aa9d60cddb82d009055262b98aff97f395d73ba9
Author: Mark Wielaard m...@redhat.com
Date:   Sun Mar 23 12:05:16 2014 +0100

PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. Including implementations for C and C++. Use this
enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
	enum_underlying_base_type defined and DWARF version  3.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/c-family/
	* c-common.c (c_enum_underlying_base_type): New function.
	* c-common.h (c_enum_underlying_base_type): Add declaration.

gcc/c/
	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c69a30c..c368854 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
+	enum_underlying_base_type defined and DWARF version  3.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
 2014-05-19  Richard Biener  rguent...@suse.de
 
 	PR tree-optimization/61184
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index c88cf59..6ff8466 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-common.c (c_enum_underlying_base_type): New function.
+	* c-common.h (c_enum_underlying_base_type): Add declaration.
+
 2014-05-17  Trevor Saunders  tsaund...@mozilla.com
 
 	* c-common.h (sorted_fields_type): Remove variable_size GTY attribute.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index a120b5c..fdc02b4 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3921,6 +3921,14 @@ c_register_builtin_type (tree type, const char* name)
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
+
+/* The C version of the enum_underlying_base_type langhook.  */
+tree
+c_enum_underlying_base_type (const_tree type)
+{
+  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+}
+
 
 /* Print an error message for invalid operands to arith operation
CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 59e809a..478d8cb 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -833,6 +833,7 @@ extern void c_common_finish (void);
 extern void c_common_parse_file (void);
 extern alias_set_type c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
+extern tree c_enum_underlying_base_type (const_tree);
 extern bool c_promoting_integer_type_p (const_tree);
 extern int self_promoting_args_p (const_tree);
 extern tree strip_pointer_operator (tree);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 1266d4e..431490d 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-05-17  Trevor Saunders  tsaund...@mozilla.com
 
 	* c-decl.c (finish_struct): Adjust.
diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h
index 92cf60f..0651db7 100644
--- a/gcc/c/c-objc-common.h
+++ b/gcc/c/c-objc-common.h
@@ -84,6 +84,8 @@ along with GCC; see the file COPYING3.  If not see
 #define LANG_HOOKS_TO_TARGET_CHARSET c_common_to_target_charset
 #undef LANG_HOOKS_EXPR_TO_DECL
 #define LANG_HOOKS_EXPR_TO_DECL c_expr_to_decl
+#undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE
+#define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE c_enum_underlying_base_type
 
 /* The C front end's scoping structure is very different from
that expected by the language-independent code; it is best
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b5ad1af..fb82778 100644
--- 

Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-19 Thread Jason Merrill

On 05/13/2014 03:21 AM, Mark Wielaard wrote:

So the debugger doesn't have to guess the properties of the enum's
underlying base type, like size, encoding and signedness.


Well, the enum already has DW_AT_byte_size.  It seems to me that it 
should also have DW_AT_encoding to provide the other two properties you 
mention.


Jason



Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-13 Thread Mark Wielaard
On Mon, May 12, 2014 at 11:22:11PM -0400, Jason Merrill wrote:
 On 04/28/2014 08:37 AM, Mark Wielaard wrote:
 The debugger cares about the actual underlying type used if the language
 can use multiple. Either explicitly assigned by the user or implicitly
 as derived by the language/compile flags used. So the lang hook should
 provide one in both cases, if appropriate.
 
 Why do you want to do this for C?  It seems to me that this is only
 interesting in C++ because of overload resolution.

So the debugger doesn't have to guess the properties of the enum's
underlying base type, like size, encoding and signedness. Which are
implementation defined and might differ between enums even in C depending
on whether -fshort-enums was used (which is the default on some arches).

Cheers,

Mark



Ping3: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-12 Thread Mark Wielaard
On Mon, 2014-04-28 at 13:17 +0200, Mark Wielaard wrote:
 On Tue, 2014-04-22 at 12:31 +0200, Mark Wielaard wrote:
  On Mon, 2014-04-14 at 23:19 +0200, Mark Wielaard wrote:
   On Fri, 2014-04-11 at 11:03 -0700, Cary Coutant wrote:
 The DWARF bits are fine with me.

 Thanks. Who can approve the other bits?

You should probably get C and C++ front end approval. I'm not really
sure who needs to review patches in c-family/. Since the part in c/ is
so tiny, maybe all you need is a C++ front end maintainer. Both
Richard Henderson and Jason Merrill are global reviewers, so either of
them could approve the whole thing.
   
   Thanks, I added them to the CC.
   
 When approved should I wait till stage 1 opens before committing?

Yes. The PR you're fixing is an enhancement request, not a regression,
so it needs to wait.
   
   Since stage one just opened up again this seems a good time to re-ask
   for approval then :) Rebased patch against current trunk attached.
  
  Ping. Tom already pushed his patches to GDB that take advantage of the
  new information if available.
 
 Ping2. Please let me know if I should ping/cc other people to get this
 reviewed.

Ping3. Rebased patch to current master attached. DWARF parts approved by
Cary, GDB already contains Tom's code to take advantage of the new
information. Please let me know if I need to take any other steps to get
this in an acceptable state and approved.

Thanks,

Mark
commit 58f1af6ee92a42d796cfd62f6158e2eb9f5969cb
Author: Mark Wielaard m...@redhat.com
Date:   Sun Mar 23 12:05:16 2014 +0100

PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. Including implementations for C and C++. Use this
enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
	enum_underlying_base_type defined and DWARF version  3.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/c-family/
	* c-common.c (c_enum_underlying_base_type): New function.
	* c-common.h (c_enum_underlying_base_type): Add declaration.

gcc/c/
	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f3cb5f7..567d268 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
+	enum_underlying_base_type defined and DWARF version  3.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
 2014-05-11  Jakub Jelinek  ja...@redhat.com
 
 	* tree.h (OMP_CLAUSE_LINEAR_STMT): Define.
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 3a978fa..c5ed7a2 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-common.c (c_enum_underlying_base_type): New function.
+	* c-common.h (c_enum_underlying_base_type): Add declaration.
+
 2014-05-09  Marek Polacek  pola...@redhat.com
 
 	PR c/50459
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index a120b5c..fdc02b4 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3921,6 +3921,14 @@ c_register_builtin_type (tree type, const char* name)
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
+
+/* The C version of the enum_underlying_base_type langhook.  */
+tree
+c_enum_underlying_base_type (const_tree type)
+{
+  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+}
+
 
 /* Print an error message for invalid operands to arith operation
CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index d34d2bb..d3d3004 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -833,6 +833,7 @@ extern void c_common_finish (void);
 extern void c_common_parse_file (void);
 extern alias_set_type c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
+extern tree c_enum_underlying_base_type (const_tree);
 extern bool c_promoting_integer_type_p (const_tree);
 extern int self_promoting_args_p (const_tree);
 extern tree strip_pointer_operator (tree);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 919b4ff..d2fb777 100644
--- 

Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-12 Thread Jason Merrill

On 04/28/2014 08:37 AM, Mark Wielaard wrote:

On Mon, 2014-04-28 at 14:23 +0200, Jakub Jelinek wrote:

Do you want to add DW_AT_type to DW_TAG_enumeration only if it has explicit
underlying type (enum class foo: char { ... };) or even when the underlying
type is computed emplicitly (then you'd just use TREE_TYPE of the
ENUMERAL_TYPE if non-NULL).


The debugger cares about the actual underlying type used if the language
can use multiple. Either explicitly assigned by the user or implicitly
as derived by the language/compile flags used. So the lang hook should
provide one in both cases, if appropriate.


Why do you want to do this for C?  It seems to me that this is only 
interesting in C++ because of overload resolution.


Jason



Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-06 Thread Mark Wielaard
On Mon, 2014-04-28 at 14:37 +0200, Mark Wielaard wrote:
 On Mon, 2014-04-28 at 14:23 +0200, Jakub Jelinek wrote:
  On Mon, Apr 28, 2014 at 01:17:32PM +0200, Mark Wielaard wrote:
   Ping2. Please let me know if I should ping/cc other people to get this
   reviewed.
  
  Do you want to add DW_AT_type to DW_TAG_enumeration only if it has explicit
  underlying type (enum class foo: char { ... };) or even when the underlying
  type is computed emplicitly (then you'd just use TREE_TYPE of the
  ENUMERAL_TYPE if non-NULL).
 
 The debugger cares about the actual underlying type used if the language
 can use multiple. Either explicitly assigned by the user or implicitly
 as derived by the language/compile flags used. So the lang hook should
 provide one in both cases, if appropriate.

Please let me know if that answered the question and whether that
information is enough to review the patch. I have attached a rebased
version against current trunk.

Thanks,

Mark
commit 6210291f2a8f01e989565ef0e7ba580144e67472
Author: Mark Wielaard m...@redhat.com
Date:   Sun Mar 23 12:05:16 2014 +0100

PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. Including implementations for C and C++. Use this
enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
	enum_underlying_base_type defined and DWARF version  3.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/c-family/
	* c-common.c (c_enum_underlying_base_type): New function.
	* c-common.h (c_enum_underlying_base_type): Add declaration.

gcc/c/
	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 41dee8f..d29281a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
+	enum_underlying_base_type defined and DWARF version  3.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
 2014-05-05  Jan Hubicka  hubi...@ucw.cz
 
 	PR ipa/60965
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 3c97323..05e5b55 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-common.c (c_enum_underlying_base_type): New function.
+	* c-common.h (c_enum_underlying_base_type): Add declaration.
+
 2014-05-02  Marek Polacek  pola...@redhat.com
 
 	* c.opt (Wsizeof-pointer-memaccess): Describe option.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 0ad955d..6862c6f 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3906,6 +3906,14 @@ c_register_builtin_type (tree type, const char* name)
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
+
+/* The C version of the enum_underlying_base_type langhook.  */
+tree
+c_enum_underlying_base_type (const_tree type)
+{
+  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+}
+
 
 /* Print an error message for invalid operands to arith operation
CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 57b7dce..25c3272 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -832,6 +832,7 @@ extern void c_common_finish (void);
 extern void c_common_parse_file (void);
 extern alias_set_type c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
+extern tree c_enum_underlying_base_type (const_tree);
 extern bool c_promoting_integer_type_p (const_tree);
 extern int self_promoting_args_p (const_tree);
 extern tree strip_pointer_operator (tree);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index e408fef..aa93750 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-05-02  Marek Polacek  pola...@redhat.com
 
 	PR c/25801
diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h
index 92cf60f..0651db7 100644
--- a/gcc/c/c-objc-common.h
+++ b/gcc/c/c-objc-common.h
@@ -84,6 +84,8 @@ along with GCC; see the file COPYING3.  If not see
 #define LANG_HOOKS_TO_TARGET_CHARSET 

Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-04-28 Thread Mark Wielaard
On Tue, 2014-04-22 at 12:31 +0200, Mark Wielaard wrote:
 On Mon, 2014-04-14 at 23:19 +0200, Mark Wielaard wrote:
  On Fri, 2014-04-11 at 11:03 -0700, Cary Coutant wrote:
The DWARF bits are fine with me.
   
Thanks. Who can approve the other bits?
   
   You should probably get C and C++ front end approval. I'm not really
   sure who needs to review patches in c-family/. Since the part in c/ is
   so tiny, maybe all you need is a C++ front end maintainer. Both
   Richard Henderson and Jason Merrill are global reviewers, so either of
   them could approve the whole thing.
  
  Thanks, I added them to the CC.
  
When approved should I wait till stage 1 opens before committing?
   
   Yes. The PR you're fixing is an enhancement request, not a regression,
   so it needs to wait.
  
  Since stage one just opened up again this seems a good time to re-ask
  for approval then :) Rebased patch against current trunk attached.
 
 Ping. Tom already pushed his patches to GDB that take advantage of the
 new information if available.

Ping2. Please let me know if I should ping/cc other people to get this
reviewed.

Thanks,

Mark
commit 603223a974054aa52512ca08f36f1550692240e5
Author: Mark Wielaard m...@redhat.com
Date:   Sun Mar 23 12:05:16 2014 +0100

PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. Including implementations for C and C++. Use this
enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
	enum_underlying_base_type defined and DWARF version  3.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/c-family/
	* c-common.c (c_enum_underlying_base_type): New function.
	* c-common.h (c_enum_underlying_base_type): Add declaration.

gcc/c/
	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b25f1f6..766e0e7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
+	enum_underlying_base_type defined and DWARF version  3.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
 2014-04-27  Richard Sandiford  rdsandif...@googlemail.com
 
 	* cselib.c (find_slot_memmode): Delete.
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index fb0d102..e652c1b 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-common.c (c_enum_underlying_base_type): New function.
+	* c-common.h (c_enum_underlying_base_type): Add declaration.
+
 2014-04-25  Marek Polacek  pola...@redhat.com
 
 	PR c/18079
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 0ad955d..6862c6f 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3906,6 +3906,14 @@ c_register_builtin_type (tree type, const char* name)
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
+
+/* The C version of the enum_underlying_base_type langhook.  */
+tree
+c_enum_underlying_base_type (const_tree type)
+{
+  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+}
+
 
 /* Print an error message for invalid operands to arith operation
CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 57b7dce..25c3272 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -832,6 +832,7 @@ extern void c_common_finish (void);
 extern void c_common_parse_file (void);
 extern alias_set_type c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
+extern tree c_enum_underlying_base_type (const_tree);
 extern bool c_promoting_integer_type_p (const_tree);
 extern int self_promoting_args_p (const_tree);
 extern tree strip_pointer_operator (tree);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 80841af..1eb3782 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-04-25  Marek Polacek  pola...@redhat.com
 
 	PR c/18079
diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h
index 92cf60f..0651db7 

Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-04-28 Thread Jakub Jelinek
On Mon, Apr 28, 2014 at 01:17:32PM +0200, Mark Wielaard wrote:
 On Tue, 2014-04-22 at 12:31 +0200, Mark Wielaard wrote:
  On Mon, 2014-04-14 at 23:19 +0200, Mark Wielaard wrote:
   On Fri, 2014-04-11 at 11:03 -0700, Cary Coutant wrote:
 The DWARF bits are fine with me.

 Thanks. Who can approve the other bits?

You should probably get C and C++ front end approval. I'm not really
sure who needs to review patches in c-family/. Since the part in c/ is
so tiny, maybe all you need is a C++ front end maintainer. Both
Richard Henderson and Jason Merrill are global reviewers, so either of
them could approve the whole thing.
   
   Thanks, I added them to the CC.
   
 When approved should I wait till stage 1 opens before committing?

Yes. The PR you're fixing is an enhancement request, not a regression,
so it needs to wait.
   
   Since stage one just opened up again this seems a good time to re-ask
   for approval then :) Rebased patch against current trunk attached.
  
  Ping. Tom already pushed his patches to GDB that take advantage of the
  new information if available.
 
 Ping2. Please let me know if I should ping/cc other people to get this
 reviewed.

Do you want to add DW_AT_type to DW_TAG_enumeration only if it has explicit
underlying type (enum class foo: char { ... };) or even when the underlying
type is computed emplicitly (then you'd just use TREE_TYPE of the
ENUMERAL_TYPE if non-NULL).

Jakub


Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-04-28 Thread Mark Wielaard
On Mon, 2014-04-28 at 14:23 +0200, Jakub Jelinek wrote:
 On Mon, Apr 28, 2014 at 01:17:32PM +0200, Mark Wielaard wrote:
  Ping2. Please let me know if I should ping/cc other people to get this
  reviewed.
 
 Do you want to add DW_AT_type to DW_TAG_enumeration only if it has explicit
 underlying type (enum class foo: char { ... };) or even when the underlying
 type is computed emplicitly (then you'd just use TREE_TYPE of the
 ENUMERAL_TYPE if non-NULL).

The debugger cares about the actual underlying type used if the language
can use multiple. Either explicitly assigned by the user or implicitly
as derived by the language/compile flags used. So the lang hook should
provide one in both cases, if appropriate.

Cheers,

Mark



Ping: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-04-22 Thread Mark Wielaard
On Mon, 2014-04-14 at 23:19 +0200, Mark Wielaard wrote:
 On Fri, 2014-04-11 at 11:03 -0700, Cary Coutant wrote:
   The DWARF bits are fine with me.
  
   Thanks. Who can approve the other bits?
  
  You should probably get C and C++ front end approval. I'm not really
  sure who needs to review patches in c-family/. Since the part in c/ is
  so tiny, maybe all you need is a C++ front end maintainer. Both
  Richard Henderson and Jason Merrill are global reviewers, so either of
  them could approve the whole thing.
 
 Thanks, I added them to the CC.
 
   When approved should I wait till stage 1 opens before committing?
  
  Yes. The PR you're fixing is an enhancement request, not a regression,
  so it needs to wait.
 
 Since stage one just opened up again this seems a good time to re-ask
 for approval then :) Rebased patch against current trunk attached.

Ping. Tom already pushed his patches to GDB that take advantage of the
new information if available.

Thanks,

Mark
From 81c76099294a9d617798ed65095d7f8210d6f958 Mon Sep 17 00:00:00 2001
From: Mark Wielaard m...@redhat.com
Date: Sun, 23 Mar 2014 12:05:16 +0100
Subject: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. Including implementations for C and C++. Use this
enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
	enum_underlying_base_type defined and DWARF version  3.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/c-family/
	* c-common.c (c_enum_underlying_base_type): New function.
	* c-common.h (c_enum_underlying_base_type): Add declaration.

gcc/c/
	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
---
 gcc/ChangeLog   |   10 ++
 gcc/c-family/ChangeLog  |6 ++
 gcc/c-family/c-common.c |8 
 gcc/c-family/c-common.h |1 +
 gcc/c/ChangeLog |5 +
 gcc/c/c-objc-common.h   |2 ++
 gcc/cp/ChangeLog|6 ++
 gcc/cp/cp-lang.c|   18 ++
 gcc/dwarf2out.c |6 ++
 gcc/langhooks-def.h |4 +++-
 gcc/langhooks.h |2 ++
 11 files changed, 67 insertions(+), 1 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e34c39f..26a9037 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
+	enum_underlying_base_type defined and DWARF version  3.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
 2014-04-22  Ian Bolton  ian.bol...@arm.com
 
 	* config/arm/arm-protos.h (tune_params): New struct members.
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 206b47b..0b7b7e1 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-common.c (c_enum_underlying_base_type): New function.
+	* c-common.h (c_enum_underlying_base_type): Add declaration.
+
 2014-04-14  Richard Biener  rguent...@suse.de
 	Marc Glisse  marc.gli...@inria.fr
 
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index c0e247b..a7c212f 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3902,6 +3902,14 @@ c_register_builtin_type (tree type, const char* name)
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
+
+/* The C version of the enum_underlying_base_type langhook.  */
+tree
+c_enum_underlying_base_type (const_tree type)
+{
+  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+}
+
 
 /* Print an error message for invalid operands to arith operation
CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 24959d8..d433972 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -832,6 +832,7 @@ extern void c_common_finish (void);
 extern void c_common_parse_file (void);
 extern alias_set_type c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
+extern tree c_enum_underlying_base_type (const_tree);
 extern bool c_promoting_integer_type_p (const_tree);
 extern int self_promoting_args_p (const_tree);
 extern tree strip_pointer_operator (tree);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index bacfbe3..cf4252b 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog

Re: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-04-14 Thread Mark Wielaard
On Fri, 2014-04-11 at 11:03 -0700, Cary Coutant wrote:
  The DWARF bits are fine with me.
 
  Thanks. Who can approve the other bits?
 
 You should probably get C and C++ front end approval. I'm not really
 sure who needs to review patches in c-family/. Since the part in c/ is
 so tiny, maybe all you need is a C++ front end maintainer. Both
 Richard Henderson and Jason Merrill are global reviewers, so either of
 them could approve the whole thing.

Thanks, I added them to the CC.

  When approved should I wait till stage 1 opens before committing?
 
 Yes. The PR you're fixing is an enhancement request, not a regression,
 so it needs to wait.

Since stage one just opened up again this seems a good time to re-ask
for approval then :) Rebased patch against current trunk attached.

Thanks,

Mark


commit a5044d478738e2fbd471b8b9d98e1b37e5d8b64b
Author: Mark Wielaard m...@redhat.com
Date:   Sun Mar 23 12:05:16 2014 +0100

PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. Including implementations for C and C++. Use this
enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
base type reference to a DW_TAG_enumeration.

gcc/
* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
enum_underlying_base_type defined and DWARF version  3.
* langhooks.h (struct lang_hooks_for_types): Add
enum_underlying_base_type.
* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/c-family/
* c-common.c (c_enum_underlying_base_type): New function.
* c-common.h (c_enum_underlying_base_type): Add declaration.

gcc/c/
* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

gcc/cp/
* cp-lang.c (cxx_enum_underlying_base_type): New function.
(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 355ba29..2a8f3ee 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,15 @@
 2014-03-21  Mark Wielaard  m...@redhat.com
 
+   PR debug/16063
+   * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
+   enum_underlying_base_type defined and DWARF version  3.
+   * langhooks.h (struct lang_hooks_for_types): Add
+   enum_underlying_base_type.
+   * langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+   (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
+2014-03-21  Mark Wielaard  m...@redhat.com
+
* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_const_value
as unsigned or int depending on type and value used.
 
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 206b47b..0b7b7e1 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+   PR debug/16063
+   * c-common.c (c_enum_underlying_base_type): New function.
+   * c-common.h (c_enum_underlying_base_type): Add declaration.
+
 2014-04-14  Richard Biener  rguent...@suse.de
Marc Glisse  marc.gli...@inria.fr
 
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index c0e247b..a7c212f 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3902,6 +3902,14 @@ c_register_builtin_type (tree type, const char* name)
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
+
+/* The C version of the enum_underlying_base_type langhook.  */
+tree
+c_enum_underlying_base_type (const_tree type)
+{
+  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+}
+
 
 /* Print an error message for invalid operands to arith operation
CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 24959d8..d433972 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -832,6 +832,7 @@ extern void c_common_finish (void);
 extern void c_common_parse_file (void);
 extern alias_set_type c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
+extern tree c_enum_underlying_base_type (const_tree);
 extern bool c_promoting_integer_type_p (const_tree);
 extern int self_promoting_args_p (const_tree);
 extern tree strip_pointer_operator (tree);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index bacfbe3..cf4252b 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+   PR debug/16063
+   * c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-04-12  Igor Zamyatin  igor.zamya...@intel.com
 
PR middle-end/60469
diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h
index 92cf60f..0651db7 100644
--- a/gcc/c/c-objc-common.h
+++ b/gcc/c/c-objc-common.h
@@ -84,6 +84,8 @@ along with GCC; see the 

Re: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-04-11 Thread Mark Wielaard
On Thu, 2014-04-10 at 10:51 -0700, Cary Coutant wrote:
  However it would be nice to be assured that the gcc change is ok in
  principle first.
 
 The DWARF bits are fine with me.

Thanks. Who can approve the other bits?
When approved should I wait till stage 1 opens before committing?

Thanks,

Mark



Re: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-04-11 Thread Cary Coutant
 The DWARF bits are fine with me.

 Thanks. Who can approve the other bits?

You should probably get C and C++ front end approval. I'm not really
sure who needs to review patches in c-family/. Since the part in c/ is
so tiny, maybe all you need is a C++ front end maintainer. Both
Richard Henderson and Jason Merrill are global reviewers, so either of
them could approve the whole thing.

 When approved should I wait till stage 1 opens before committing?

Yes. The PR you're fixing is an enhancement request, not a regression,
so it needs to wait.

-cary


Re: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-04-10 Thread Tom Tromey
 Mark == Mark Wielaard m...@redhat.com writes:

Mark Add a new lang-hook that provides the underlying base type of an
Mark ENUMERAL_TYPE. Including implementations for C and C++. Use this
Mark enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
Mark base type reference to a DW_TAG_enumeration.

Just FYI - I sent a patch for gdb to use this information.
I'll probably put it in before the gcc change goes in, on the theory
that when the gcc change goes in, nobody will have to wait to debug.
However it would be nice to be assured that the gcc change is ok in
principle first.

Tom


Re: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-04-10 Thread Cary Coutant
 However it would be nice to be assured that the gcc change is ok in
 principle first.

The DWARF bits are fine with me.

-cary


Re: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-03-26 Thread Mark Wielaard
On irc Tom Tromey pointed out that the patch generates duplicate base
type DIEs for enums with the same underlying base type. This is because
it was calling base_type_die () and adding the DW_AT_type by hand
instead of calling add_type_attribute () to add it to the enumeration
DIE. The only difference with the original patch is the following:

  {
tree underlying = lang_hooks.types.enum_underlying_base_type (type);
-   dw_die_ref underlying_die = base_type_die (underlying);
-   add_AT_die_ref (type_die, DW_AT_type, underlying_die);
+   add_type_attribute (type_die, underlying, 0, 0, context_die);
  }

This generates the same DWARF except for generating multiple instances
of the same base type DIE in case multiple enums in a CU share the same
underlying base type.
From 964dcd8a1aefb6bc733372aa42868ed3ad8a46d7 Mon Sep 17 00:00:00 2001
From: Mark Wielaard m...@redhat.com
Date: Sun, 23 Mar 2014 12:05:16 +0100
Subject: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. Including implementations for C and C++. Use this
enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
	enum_underlying_base_type defined and DWARF version  3.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/c-family/
	* c-common.c (c_enum_underlying_base_type): New function.
	* c-common.h (c_enum_underlying_base_type): Add declaration.

gcc/c/
	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
---
 gcc/ChangeLog   |   10 ++
 gcc/c-family/ChangeLog  |6 ++
 gcc/c-family/c-common.c |8 
 gcc/c-family/c-common.h |1 +
 gcc/c/ChangeLog |5 +
 gcc/c/c-objc-common.h   |2 ++
 gcc/cp/ChangeLog|6 ++
 gcc/cp/cp-lang.c|   18 ++
 gcc/dwarf2out.c |6 ++
 gcc/langhooks-def.h |4 +++-
 gcc/langhooks.h |2 ++
 11 files changed, 67 insertions(+), 1 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b456eff..7bce951 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,15 @@
 2014-03-21  Mark Wielaard  m...@redhat.com
 
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
+	enum_underlying_base_type defined and DWARF version  3.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
+2014-03-21  Mark Wielaard  m...@redhat.com
+
 	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_const_value
 	as unsigned or int depending on type and value used.
 
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 536b4fc..94d779d 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-common.c (c_enum_underlying_base_type): New function.
+	* c-common.h (c_enum_underlying_base_type): Add declaration.
+
 2014-03-22  Jakub Jelinek  ja...@redhat.com
 
 	PR debug/60603
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index abd96fb..55ebbcc 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3902,6 +3902,14 @@ c_register_builtin_type (tree type, const char* name)
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
+
+/* The C version of the enum_underlying_base_type langhook.  */
+tree
+c_enum_underlying_base_type (const_tree type)
+{
+  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+}
+
 
 /* Print an error message for invalid operands to arith operation
CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 1099b10..e378b44 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -832,6 +832,7 @@ extern void c_common_finish (void);
 extern void c_common_parse_file (void);
 extern alias_set_type c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
+extern tree c_enum_underlying_base_type (const_tree);
 extern bool c_promoting_integer_type_p (const_tree);
 extern int self_promoting_args_p (const_tree);
 extern tree strip_pointer_operator (tree);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index b39b7d6..9ab6eab 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-03-18

Re: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-03-25 Thread Mark Wielaard
On Mon, 2014-03-24 at 09:57 -0700, Cary Coutant wrote:
  gcc/cp/
  * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
  enum_underlying_base_type defined and DWARF version  3.
  * langhooks.h (struct lang_hooks_for_types): Add
  enum_underlying_base_type.
  * langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New 
  define.
  (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
 
 This should be the ChangeLog entry for cp/cp-lang.c.

Yes, you are right. Sorry for the copy/paste error.
Attached is the updated commit message and patch.

Thanks,

Mark
From b92c7933ebf8a09a97ca2419d253a0ac1acdca6f Mon Sep 17 00:00:00 2001
From: Mark Wielaard m...@redhat.com
Date: Sun, 23 Mar 2014 12:05:16 +0100
Subject: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. Including implementations for C and C++. Use this
enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
	enum_underlying_base_type defined and DWARF version  3.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/c-family/
	* c-common.c (c_enum_underlying_base_type): New function.
	* c-common.h (c_enum_underlying_base_type): Add declaration.

gcc/c/
	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
---
 gcc/ChangeLog   |   10 ++
 gcc/c-family/ChangeLog  |6 ++
 gcc/c-family/c-common.c |8 
 gcc/c-family/c-common.h |1 +
 gcc/c/ChangeLog |5 +
 gcc/c/c-objc-common.h   |2 ++
 gcc/cp/ChangeLog|6 ++
 gcc/cp/cp-lang.c|   18 ++
 gcc/dwarf2out.c |7 +++
 gcc/langhooks-def.h |4 +++-
 gcc/langhooks.h |2 ++
 11 files changed, 68 insertions(+), 1 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b456eff..7bce951 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,15 @@
 2014-03-21  Mark Wielaard  m...@redhat.com
 
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
+	enum_underlying_base_type defined and DWARF version  3.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
+2014-03-21  Mark Wielaard  m...@redhat.com
+
 	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_const_value
 	as unsigned or int depending on type and value used.
 
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 536b4fc..94d779d 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-common.c (c_enum_underlying_base_type): New function.
+	* c-common.h (c_enum_underlying_base_type): Add declaration.
+
 2014-03-22  Jakub Jelinek  ja...@redhat.com
 
 	PR debug/60603
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index abd96fb..55ebbcc 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3902,6 +3902,14 @@ c_register_builtin_type (tree type, const char* name)
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
+
+/* The C version of the enum_underlying_base_type langhook.  */
+tree
+c_enum_underlying_base_type (const_tree type)
+{
+  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+}
+
 
 /* Print an error message for invalid operands to arith operation
CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 1099b10..e378b44 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -832,6 +832,7 @@ extern void c_common_finish (void);
 extern void c_common_parse_file (void);
 extern alias_set_type c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
+extern tree c_enum_underlying_base_type (const_tree);
 extern bool c_promoting_integer_type_p (const_tree);
 extern int self_promoting_args_p (const_tree);
 extern tree strip_pointer_operator (tree);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index b39b7d6..9ab6eab 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-03-18  Manuel López-Ibáñez  m...@gcc.gnu.org
 
 	PR c/55383
diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h
index 92cf60f..0651db7 100644
--- a/gcc/c/c-objc

Re: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-03-24 Thread Richard Biener
On Sun, Mar 23, 2014 at 12:18 PM, Mark Wielaard m...@redhat.com wrote:
 Add a new lang-hook that provides the underlying base type of an
 ENUMERAL_TYPE. Including implementations for C and C++. Use this
 enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
 base type reference to a DW_TAG_enumeration.

Don't we have TREE_TYPE (enum-type) as that type?  Thus, can we avoid
adding the new langhook?

Thanks,
Richard.

 gcc/
 * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
 enum_underlying_base_type defined and DWARF version  3.
 * langhooks.h (struct lang_hooks_for_types): Add
 enum_underlying_base_type.
 * langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
 (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

 gcc/c-family/
 * c-common.c (c_enum_underlying_base_type): New function.
 * c-common.h (c_enum_underlying_base_type): Add declaration.

 gcc/c/
 * c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

 gcc/cp/
 * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
 enum_underlying_base_type defined and DWARF version  3.
 * langhooks.h (struct lang_hooks_for_types): Add
 enum_underlying_base_type.
 * langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
 (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
 ---
  gcc/ChangeLog   |   10 ++
  gcc/c-family/ChangeLog  |6 ++
  gcc/c-family/c-common.c |8 
  gcc/c-family/c-common.h |1 +
  gcc/c/ChangeLog |5 +
  gcc/c/c-objc-common.h   |2 ++
  gcc/cp/ChangeLog|6 ++
  gcc/cp/cp-lang.c|   18 ++
  gcc/dwarf2out.c |7 +++
  gcc/langhooks-def.h |4 +++-
  gcc/langhooks.h |2 ++
  11 files changed, 68 insertions(+), 1 deletions(-)

 diff --git a/gcc/ChangeLog b/gcc/ChangeLog
 index f3b4f2d..e90ea6e 100644
 --- a/gcc/ChangeLog
 +++ b/gcc/ChangeLog
 @@ -1,5 +1,15 @@
  2014-03-21  Mark Wielaard  m...@redhat.com

 +   PR debug/16063
 +   * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
 +   enum_underlying_base_type defined and DWARF version  3.
 +   * langhooks.h (struct lang_hooks_for_types): Add
 +   enum_underlying_base_type.
 +   * langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
 +   (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
 +
 +2014-03-21  Mark Wielaard  m...@redhat.com
 +
 * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_const_value
 as unsigned or int depending on type and value used.

 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
 index 4e5aea4..90b688b 100644
 --- a/gcc/c-family/ChangeLog
 +++ b/gcc/c-family/ChangeLog
 @@ -1,3 +1,9 @@
 +2014-03-21  Mark Wielaard  m...@redhat.com
 +
 +   PR debug/16063
 +   * c-common.c (c_enum_underlying_base_type): New function.
 +   * c-common.h (c_enum_underlying_base_type): Add declaration.
 +
  2014-03-13  Jakub Jelinek  ja...@redhat.com

 PR middle-end/36282
 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
 index abd96fb..55ebbcc 100644
 --- a/gcc/c-family/c-common.c
 +++ b/gcc/c-family/c-common.c
 @@ -3902,6 +3902,14 @@ c_register_builtin_type (tree type, const char* name)

registered_builtin_types = tree_cons (0, type, registered_builtin_types);
  }
 +
 +/* The C version of the enum_underlying_base_type langhook.  */
 +tree
 +c_enum_underlying_base_type (const_tree type)
 +{
 +  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED 
 (type));
 +}
 +

  /* Print an error message for invalid operands to arith operation
 CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
 diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
 index 1099b10..e378b44 100644
 --- a/gcc/c-family/c-common.h
 +++ b/gcc/c-family/c-common.h
 @@ -832,6 +832,7 @@ extern void c_common_finish (void);
  extern void c_common_parse_file (void);
  extern alias_set_type c_common_get_alias_set (tree);
  extern void c_register_builtin_type (tree, const char*);
 +extern tree c_enum_underlying_base_type (const_tree);
  extern bool c_promoting_integer_type_p (const_tree);
  extern int self_promoting_args_p (const_tree);
  extern tree strip_pointer_operator (tree);
 diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
 index b39b7d6..9ab6eab 100644
 --- a/gcc/c/ChangeLog
 +++ b/gcc/c/ChangeLog
 @@ -1,3 +1,8 @@
 +2014-03-21  Mark Wielaard  m...@redhat.com
 +
 +   PR debug/16063
 +   * c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
 +
  2014-03-18  Manuel López-Ibáñez  m...@gcc.gnu.org

 PR c/55383
 diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h
 index 92cf60f..0651db7 100644
 --- a/gcc/c/c-objc-common.h
 +++ b/gcc/c/c-objc-common.h
 @@ -84,6 +84,8 @@ along with GCC; see the file COPYING3.  If not see
  #define 

Re: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-03-24 Thread Mark Wielaard
On Mon, 2014-03-24 at 10:26 +0100, Richard Biener wrote:
 On Sun, Mar 23, 2014 at 12:18 PM, Mark Wielaard m...@redhat.com wrote:
  Add a new lang-hook that provides the underlying base type of an
  ENUMERAL_TYPE. Including implementations for C and C++. Use this
  enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
  base type reference to a DW_TAG_enumeration.
 
 Don't we have TREE_TYPE (enum-type) as that type?  Thus, can we avoid
 adding the new langhook?

The underlying type is the integral base type of the enum, which, at
least for C++, can be different from the tree type of the enum. See also
cp/semantics.c (finish_underlying_type) which calculates it in the C++
case.

Cheers,

Mark



Re: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-03-24 Thread Cary Coutant
 gcc/cp/
 * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
 enum_underlying_base_type defined and DWARF version  3.
 * langhooks.h (struct lang_hooks_for_types): Add
 enum_underlying_base_type.
 * langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
 (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

This should be the ChangeLog entry for cp/cp-lang.c.

-cary


[PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-03-23 Thread Mark Wielaard
Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. Including implementations for C and C++. Use this
enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
base type reference to a DW_TAG_enumeration.

gcc/
* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
enum_underlying_base_type defined and DWARF version  3.
* langhooks.h (struct lang_hooks_for_types): Add
enum_underlying_base_type.
* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/c-family/
* c-common.c (c_enum_underlying_base_type): New function.
* c-common.h (c_enum_underlying_base_type): Add declaration.

gcc/c/
* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

gcc/cp/
* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
enum_underlying_base_type defined and DWARF version  3.
* langhooks.h (struct lang_hooks_for_types): Add
enum_underlying_base_type.
* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
---
 gcc/ChangeLog   |   10 ++
 gcc/c-family/ChangeLog  |6 ++
 gcc/c-family/c-common.c |8 
 gcc/c-family/c-common.h |1 +
 gcc/c/ChangeLog |5 +
 gcc/c/c-objc-common.h   |2 ++
 gcc/cp/ChangeLog|6 ++
 gcc/cp/cp-lang.c|   18 ++
 gcc/dwarf2out.c |7 +++
 gcc/langhooks-def.h |4 +++-
 gcc/langhooks.h |2 ++
 11 files changed, 68 insertions(+), 1 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f3b4f2d..e90ea6e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,15 @@
 2014-03-21  Mark Wielaard  m...@redhat.com
 
+   PR debug/16063
+   * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
+   enum_underlying_base_type defined and DWARF version  3.
+   * langhooks.h (struct lang_hooks_for_types): Add
+   enum_underlying_base_type.
+   * langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+   (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
+2014-03-21  Mark Wielaard  m...@redhat.com
+
* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_const_value
as unsigned or int depending on type and value used.
 
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 4e5aea4..90b688b 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+   PR debug/16063
+   * c-common.c (c_enum_underlying_base_type): New function.
+   * c-common.h (c_enum_underlying_base_type): Add declaration.
+
 2014-03-13  Jakub Jelinek  ja...@redhat.com
 
PR middle-end/36282
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index abd96fb..55ebbcc 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3902,6 +3902,14 @@ c_register_builtin_type (tree type, const char* name)
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
+
+/* The C version of the enum_underlying_base_type langhook.  */
+tree
+c_enum_underlying_base_type (const_tree type)
+{
+  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+}
+
 
 /* Print an error message for invalid operands to arith operation
CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 1099b10..e378b44 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -832,6 +832,7 @@ extern void c_common_finish (void);
 extern void c_common_parse_file (void);
 extern alias_set_type c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
+extern tree c_enum_underlying_base_type (const_tree);
 extern bool c_promoting_integer_type_p (const_tree);
 extern int self_promoting_args_p (const_tree);
 extern tree strip_pointer_operator (tree);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index b39b7d6..9ab6eab 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+   PR debug/16063
+   * c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-03-18  Manuel López-Ibáñez  m...@gcc.gnu.org
 
PR c/55383
diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h
index 92cf60f..0651db7 100644
--- a/gcc/c/c-objc-common.h
+++ b/gcc/c/c-objc-common.h
@@ -84,6 +84,8 @@ along with GCC; see the file COPYING3.  If not see
 #define LANG_HOOKS_TO_TARGET_CHARSET c_common_to_target_charset
 #undef LANG_HOOKS_EXPR_TO_DECL
 #define LANG_HOOKS_EXPR_TO_DECL c_expr_to_decl
+#undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE
+#define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE c_enum_underlying_base_type
 
 /* The C front end's scoping structure is