diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-03-09 17:42:45 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-03-09 17:42:45 +0100 |
commit | 01e5af5a2f5fa4813e359bc03d42e98d091c7a2d (patch) | |
tree | 00751fa0f7edfc1585af540a59ca67baebbdd525 | |
parent | 6443c7c0e5e1b348ff5841463e3c3828b3036e30 (diff) | |
download | gcc-01e5af5a2f5fa4813e359bc03d42e98d091c7a2d.zip gcc-01e5af5a2f5fa4813e359bc03d42e98d091c7a2d.tar.gz gcc-01e5af5a2f5fa4813e359bc03d42e98d091c7a2d.tar.bz2 |
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
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/debug/dwarf2/enum-loc1.c | 19 |
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 588fe73..e6da629 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -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 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 645304a..130ffa6 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cad76f2..48fba48 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/enum-loc1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/enum-loc1.c new file mode 100644 index 0000000..7394313 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/enum-loc1.c @@ -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" } } */ |