[cfe-dev] Type as written is lost here?

John McCall rjmccall at apple.com
Fri Dec 24 12:52:18 PST 2010


On Dec 24, 2010, at 12:46 AM, Abramo Bagnara wrote:
> $ cat z.c
> typedef void *f();
> 
> f a;
> f b __attribute__((noreturn));
> 
> void g(f m);
> void h(f m __attribute__((noreturn)));
> $ clang -cc1 -ast-dump z.c
> typedef char *__builtin_va_list;
> typedef void *(f)();
> f a;
> void *b() __attribute((noreturn));
> void g(f m);
> void h(void *(m)() __attribute__((noreturn)));
> 
> 
> In the declarations for b and h the use of typedef f is lost.
> 
> I guess this is due to the fact that noreturn attribute is applied to
> function type and not to declaration (despite the fact that it is
> available in the declaration).
> 
> What about to introduce an AttributedTypeLoc (or to add attributes to
> QualifiedTypeLoc)?

I was just talking to Doug yesterday about the need for an AttributedType.

I think it would be somewhat awkward to take advantage of an
AttributedType right now because of the way that GetTypeForDeclarator()
builds the TypeLoc in a second pass, but I am planning to fix that,
possibly over the holidays, and as part of that I will likely add the new type.

John.



More information about the cfe-dev mailing list