[PATCH] D139195: [-Wmissing-noreturn] Detect non-void noreturn function candidates

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 2 07:31:54 PST 2022


aaron.ballman added a comment.

> Previously, only void returning functions were considered for noreturn attribute candidates. This patch removes this artificial restriction.

C2x 6.7.12.6p6: The implementation should produce a diagnostic message for a function declared with a noreturn attribute that appears to be capable of returning to its caller.

p7 has an example showing `[[noreturn]] int h(void);` with the comment "Implementations are similarly encouraged to diagnose the declaration of h() because it appears capable of returning to its caller due to the non-void return type."

So is this really an artificial restriction? To me, putting the `noreturn` attribute on a function with a return type makes no sense whatsoever. The interface is saying "I promise that calling me will not return" and "when I return, this is the type of the value I will give you."


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139195/new/

https://reviews.llvm.org/D139195



More information about the cfe-commits mailing list