Bug 44668 - class->DW_TAG_typedef is missing DW_AT_accessibility
Summary: class->DW_TAG_typedef is missing DW_AT_accessibility
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.1
: P3 minor
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-25 16:22 UTC by Jan Kratochvil
Modified: 2010-07-27 08:48 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
gcc46-pr44668.patch (398 bytes, patch)
2010-06-25 16:53 UTC, Jakub Jelinek
Details | Diff
gcc46-pr44668.patch (1.52 KB, patch)
2010-06-25 18:23 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2010-06-25 16:22:24 UTC
echo 'class C { protected: typedef int t; t v; } c;' | g++ -Wall -c -g -x c++ -

 <2><33>: Abbrev Number: 3 (DW_TAG_typedef)
    <34>   DW_AT_name        : t        
    <38>   DW_AT_type        : <0x4a>   
 <2><3c>: Abbrev Number: 4 (DW_TAG_member)
    <3d>   DW_AT_name        : v        
    <41>   DW_AT_type        : <0x33>   
    <45>   DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0)
    <48>   DW_AT_accessibility: 2       (protected)

DIE <0x33> should have DW_AT_accessibility.

FAIL g++ (GCC) 4.6.0 20100625 (experimental)
FAIL g++ (GCC) 4.5.1 20100625 (prerelease)
SKIP g++ (GCC) 4.4.5 20100625 (prerelease) - C::t is missing there.
FAIL gcc-c++-4.4.4-8.fc14.x86_64

G++ properly respects the access control:
.C:3: error: ‘typedef int C::t’ is protected
.C:11: error: within this context

But GDB cannot display the access control during `ptype C'.
GDB does not and probably should not respect the access control, though.
Comment 1 Jan Kratochvil 2010-06-25 16:31:59 UTC
Dependent GDB Bug:
http://sourceware.org/bugzilla/show_bug.cgi?id=11757
Comment 2 Jakub Jelinek 2010-06-25 16:53:32 UTC
Created attachment 21005 [details]
gcc46-pr44668.patch

Patch to fix this for typedefs.  More work will be needed to handle it for other DW_TAG_* type dies.

// PR debug/44668
// { dg-do compile }
// { dg-options "-g -dA" }

struct C
{
private:
  typedef int a;
  a b;
  enum g { g1, g2 } h;
  struct D { int i; } i;
protected:
  typedef int c;
  c d;
public:
  typedef int e;
  e f;
} c;
Comment 3 Jakub Jelinek 2010-06-25 18:23:16 UTC
Created attachment 21006 [details]
gcc46-pr44668.patch

Updated patch.
Comment 4 Jakub Jelinek 2010-06-29 19:37:59 UTC
Subject: Bug 44668

Author: jakub
Date: Tue Jun 29 19:37:46 2010
New Revision: 161563

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161563
Log:
	PR debug/44668
	* dwarf2out.c (add_accessibility_attribute): New function.
	(gen_subprogram_die, gen_variable_die, gen_field_die): Use it
	instead of adding DW_AT_accessibility manually.
	(gen_enumeration_type_die, gen_struct_or_union_type_die,
	gen_typedef_die): Use it.

	* g++.dg/debug/dwarf2/accessibility1.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/accessibility1.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 Jakub Jelinek 2010-07-27 08:48:17 UTC
Fixed.