Type as written is lost here?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Type as written is lost here?

Abramo Bagnara-2

$ 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)?
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Type as written is lost here?

John McCall
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.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev