[cfe-dev] Fwd: Re: Invalid noreturn

Sean Hunt rideau3 at gmail.com
Thu Dec 17 16:29:30 PST 2009

On 12/17/2009 03:35 PM, Charles Davis wrote:

>  I thought I fixed this!
>  It seems to be related to what happens after the call to the noreturn
>  function pointer. If there's nothing after it, it doesn't warn, but if
>  there's something after it, it does warn.
>  Here's another useful and interesting tidbit: if you put the noreturn
>  attribute inside the parentheses with the function name, or after the
>  parameter list, the problem goes away:
>  static void (NORETURN *die_routine)(int i); /* this works */
>  static void (*die_routine)(int i) NORETURN; /* so does this */
>  static NORETURN void (*die_routine)(int i); /* but not this */
>  static void NORETURN (*die_routine)(int i); /* and not this */
>  The reason is that, when clang sees the noreturn in the second two
>  cases, it hasn't yet seen the whole function header yet, so it tries (in
>  vain) to apply it to the return type. What we really want is for clang
>  to try to apply it to the function type, not the type it returns. I need
>  to figure this out anyway, so calling convention attributes work
>  properly in my future patches.
>  Chip
I think clang needs to be able to attach attributes to the declarator
itself, rather than the declaration. C++0x encourages this
interpretation (but, interestingly enough, not for [[noreturn]].
Possibly a defect?).


More information about the cfe-dev mailing list