re PR c/79969 (C FE emits locus of forward enum declaration rather than definition into debug info)

PR c/79969
	* c-decl.c (start_enum): Adjust DECL_SOURCE_LOCATION of
	TYPE_STUB_DECL.

	* gcc.dg/debug/dwarf2/enum-loc1.c: New test.

From-SVN: r246009
This commit is contained in:
Jakub Jelinek 2017-03-09 17:42:45 +01:00 committed by Jakub Jelinek
parent 6443c7c0e5
commit 01e5af5a2f
4 changed files with 34 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2017-03-09 Jakub Jelinek <jakub@redhat.com>
PR c/79969
* c-decl.c (start_enum): Adjust DECL_SOURCE_LOCATION of
TYPE_STUB_DECL.
2017-03-07 Jakub Jelinek <jakub@redhat.com>
PR c/79834

View File

@ -8201,6 +8201,10 @@ start_enum (location_t loc, struct c_enum_contents *the_enum, tree name)
enumtype = make_node (ENUMERAL_TYPE);
pushtag (loc, name, enumtype);
}
/* Update type location to the one of the definition, instead of e.g.
a forward declaration. */
else if (TYPE_STUB_DECL (enumtype))
DECL_SOURCE_LOCATION (TYPE_STUB_DECL (enumtype)) = loc;
if (C_TYPE_BEING_DEFINED (enumtype))
error_at (loc, "nested redefinition of %<enum %E%>", name);

View File

@ -1,3 +1,8 @@
2017-03-09 Jakub Jelinek <jakub@redhat.com>
PR c/79969
* gcc.dg/debug/dwarf2/enum-loc1.c: New test.
2017-03-09 Marek Polacek <polacek@redhat.com>
PR c++/79687

View File

@ -0,0 +1,19 @@
/* PR c/79969 */
/* { dg-do compile } */
/* { dg-options "-gdwarf -dA -fno-merge-debug-strings" } */
enum ENUMTAG;
enum ENUMTAG
{
B = 1,
C = 2
};
void
bar (void)
{
enum ENUMTAG a = C;
}
/* { dg-final { scan-assembler "DW_TAG_enumeration_type\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"ENUMTAG\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^0-9a-fA-FxX](0x)?7\[^0-9a-fA-FxX]\[^\\r\\n\]*DW_AT_decl_line" } } */