[cfe-dev] Pretty printing c11 _Noreturn attribute

Aaron Ballman via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 4 05:40:17 PST 2015


On Wed, Nov 4, 2015 at 8:38 AM, Andrey Tarasevich via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> Hi all,
>
> When I’m pretty printing from AST a function with c11 _Noreturn function specifier, it is printed as an attribute, i.e. at the end of function declaration, but it should be at the front and thus code is uncompilable.
>
> Original code. Compiles
>
> ----------------------
> _Noreturn void foo(){
>   abort();
> }
>
> int main() {}
> ----------------------
>
> Same code parsed by Clang and pretty printed via TranslationUnitDecl::Print():
>
> ----------------------
> void foo() _Noreturn {  // error: '_Noreturn' keyword must precede function declarator
>   abort();
> }
>
> int main() {}
> ----------------------
>
> This happens, because C11 _Noreturn is considered to be function attribute in Clang internals, while in standard it is defined, as function-specifier just like “inline”
>
> Is this behaviour desired or it is a bug?

That's a bug with the pretty printer. It's not paying attention to
whether the attribute was spelled as a keyword or not.

~Aaron

>
> Cheers,
> Andrey
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list