-fdump-go-spec option does not handle redefinitions

Uros Bizjak ubizjak@gmail.com
Thu Oct 27 21:12:00 GMT 2011


On Thu, Oct 27, 2011 at 9:29 PM, Ian Lance Taylor <iant@google.com> wrote:

>> This testfile:
>>
>> #define aa 2
>> #undef aa
>> #define aa 3
>>
>> does not generate correct output with -fdump-go-spec. The result is:
>>
>> const _aa = 2
>> // undef _aa
>>
>> One would expect:
>>
>> const _aa = 2
>> // undef _aa
>> const _aa = 3
>
> Did this come up in a real situation?

Yes, it breaks libgo build on Alpha, due to the way TCGETS and friends
are defined. From bits/ioctls.h:

/* Use the definitions from the kernel header files.  */
#include <asm/ioctls.h>

/* Oh well, this is necessary since the kernel data structure is
   different from the user-level version.  */
#undef  TCGETS
#undef  TCSETS
#undef  TCSETSW
#undef  TCSETSF
#define TCGETS	_IOR ('t', 19, char[44])
#define TCSETS	_IOW ('t', 20, char[44])
#define TCSETSW	_IOW ('t', 21, char[44])
#define TCSETSF	_IOW ('t', 22, char[44])

> The problem with your proposal is that the output would be invalid Go,
> because it would attempt to define the name _aa twice.  However, it does
> seem plausible that in most scenarios of this type it would be more
> useful for -fdump-go-spec to generate
>
> const _aa = 3

I agree.

Thanks,
Uros.



More information about the Gcc mailing list