This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


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

Re: [RFA] enum enable


Eli Zaretskii <eliz@is.elta.co.il> writes:

>> From: Jim Blandy <jimb@zwingli.cygnus.com>
>> Date: 17 Jul 2001 12:46:32 -0500
>> 
>> Eli Zaretskii <eliz@is.elta.co.il> writes:
>> > In addition to Andrew's request to change that, GCC 2.7.2.1 barfs if
>> > it sees the declaration of a member `enable' together with a prototype
>> > of a function `enable' in the same compilation unit.  In my case, the
>> > function is declared in one of the system headers, so I guess GCC sees
>> > it first and protests when the same identifier appears in a struct.
>> 
>> You've *got* to be kidding.
>> 
>> So, the following program gets an error?
>> 
>> extern int foo (void);
>> 
>> struct bar
>> {
>>   int foo;
>> };
>> 
> 
> No, that one passes.  But this one does not:
> 
>     enum foobar
>       {
> 	foo,
> 	bar
>      };
> 
>     int foo(void);
> 
>     $ gcc2721 -c enum.c
>     enum.c:8: two or more data types in declaration of `foo'
>     enum.c:8: `foo' redeclared as different kind of symbol
>     enum.c:4: previous declaration of `foo'
> 
> If I switch the order of the function and enum declaration, the
> resulting message might give a clue about what's going on:
> 
>     int foo(void);
> 
>     enum foobar
>       {
> 	foo,
> 	bar
>      };
> 
>     $ gcc2721 -c enum.c
>     enum.c:6: `foo' redeclared as different kind of symbol
>     enum.c:2: previous declaration of `foo'
>     enum.c:6: warning: `foo' was declared `extern' and later `static'
> 
> Actually, now I see that even GCC 2.95.3 reports the same errors.
> 
> [Dig, dig] and it looks like this is expected: my references indicate
> that enumeration constants and function names belong to the same
> namespace in C programs.

Yeah, but in case you still thought gcc was off the hook for this type
of failure, check this out:

#include <vector>
struct fill {}; // comment out this line to compile successfully
struct y {};
void f()
{
   std::vector<y> x(10);
   x.insert(x.begin(), 10, y());
}

Works fine with 2.95. Perfectly valid C++.
Fails miserably with 3.0.

Whoops.
:)
--Dan


-- 
"Women...  Can't live with 'em...  Can't shoot 'em.
"-Steven Wright


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