https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90485
Bug ID: 90485 Summary: Improve error message for throw/noexcept/const after function attribute Product: gcc Version: 9.1.0 Status: UNCONFIRMED Keywords: diagnostic Severity: minor Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fw at gcc dot gnu.org Target Milestone: --- Consider this: void f1() __attribute__ ((__noreturn__)) throw (); void f2() __attribute__ ((__noreturn__)) noexcept; void f3() __attribute__ ((__noreturn__)) const; void f4() [[gnu::noreturn]] const; And: t.c:1:42: error: expected initializer before ‘throw’ 1 | void f1() __attribute__ ((__noreturn__)) throw (); | ^~~~~ t.c:2:42: error: expected initializer before ‘noexcept’ 2 | void f2() __attribute__ ((__noreturn__)) noexcept; | ^~~~~~~~ t.c:3:42: error: expected initializer before ‘const’ 3 | void f3() __attribute__ ((__noreturn__)) const; | ^~~~~ t.c:4:29: error: expected initializer before ‘const’ 4 | void f4() [[gnu::noreturn]] const; | ^~~~~ As usual, it is sort of obvious if you know what is going on, but I think an explicit “function attributes must come after <keyword>” would be helpful. I encountered this with the __THROW macro in glibc, which makes things slightly worse.