[cfe-dev] Pretty printing c11 _Noreturn attribute

Andrey Tarasevich via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 4 05:38:46 PST 2015


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?

Cheers,
Andrey


More information about the cfe-dev mailing list