This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++0x] implementing forward declarations for enums


On Tue, Oct 12, 2010 at 3:05 PM, Ed Smith-Rowland <3dw4rd@verizon.net> wrote:
> ../../gcc_enumdecl/gcc/cp/decl.c:11454:6: error: 'prevtype' may be used
> uninitialized in this function [-Werror=uninitialized]
> cc1: all warnings being treated as errors
>
>
> tree
> start_enum (tree name, tree enumtype, tree underlying_type,
> Â Â Â Âbool scoped_enum_p, bool *is_new)
> {
> Âtree prevtype = NULL_TREE;
> Âgcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
>
> Other than that it looks good to me.
The same warning again! Thank you for your review, Ed.

Jason: I've been looking to the debugging information problem. I moved
the call to rest_of_type_compilation from finish_enum to
finish_enum_value_list, as you suggested previously.
Here are the results, with an example:
---------------8<-------------
//a.cpp:
enum E : int;
E x;
enum E : int { A, B, C };

enum U : int { X, Y, Z };
U y;

enum V : int;
V z;

int main()
{
    return 0;
}
---------------8<-------------
$ g++ -O0 -gdwarf-2 -std=c++0x a.cpp
$ gdb ./a.out
(gdb) start
...
(gdb) p x
$1 = A
(gdb) p y
$2 = X
(gdb) p z
$3 = 0
(gdb) ptype x
type = enum E {A, B, C}
(gdb) ptype y
type = enum U {X, Y, Z}
(gdb) ptype z
type = enum V {}
(gdb) p sizeof x
$4 = 4
(gdb) p sizeof y
$5 = 4
(gdb) p sizeof z
$6 = 4
(gdb)

---------------8<-------------
$ g++ -O0 -gstabs+ -std=c++0x a.cpp
$ gdb ./a.out
(gdb) start
...
(gdb) p x
$1 = A
(gdb) p y
$2 = X
(gdb) p z
$3 = <incomplete type>
(gdb) ptype x
type = enum {A, B, C}
(gdb) ptype y
type = enum {X, Y, Z}
(gdb) ptype z
type = enum V {}
(gdb) p sizeof x
$4 = 4
(gdb) p sizeof y
$5 = 4
(gdb) p sizeof z
$6 = 0
(gdb)

The other formats are not supported in my linux box, I think.
The only problem I can see is that the STABS treats the enum V as
incomplete because it lack debugging information (it called
finish_enum but not finish_enum_value_list).
The DWARF, however, manages to get it right.

What do you think of the following? The enumeration types are inserted
into a list when calling finish_enum, and then when the compilation
unit is finished, it dumps all the debug info for the types not
already dumped.

Other option would be to use the  flag of the VALUE_LIST to modify the
debuggers backed.

Regards.
Rodrigo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]