public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* __attribute__ error ("message")
@ 2023-03-31 21:54 Jonny Grant
  2023-03-31 21:57 ` Jonathan Wakely
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jonny Grant @ 2023-03-31 21:54 UTC (permalink / raw)
  To: gcc-help

Hello

May I check, does this attribute error output the error message usually?
My example links fine without any warnings or errors.

Maybe I am misunderstanding it. I am sharing a simple program below and godbolt trunk example.
I only get to see the error message if I don't implement the function and get a link failure.

https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes

error ("message")
warning ("message")

If the error or warning attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, an error or warning (respectively) that includes message is diagnosed. 



https://godbolt.org/z/n849GPTjj


void compile_abort() __attribute__((error("compile abort")));

void compile_abort()
{
    __builtin_abort();
}

int main()
{
    compile_abort();
}

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-04-10 23:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-31 21:54 __attribute__ error ("message") Jonny Grant
2023-03-31 21:57 ` Jonathan Wakely
2023-03-31 21:58 ` Xi Ruoyao
2023-03-31 22:12   ` Jonny Grant
2023-03-31 22:13     ` Xi Ruoyao
2023-04-01 16:57       ` Jonny Grant
2023-04-01 23:00         ` Jonathan Wakely
2023-04-10 23:06           ` Jonny Grant
2023-04-01 17:11 ` Warning for unsafe/insecure functions Rajeev Bansal
2023-04-01 18:50   ` Xi Ruoyao
2023-04-02  2:12     ` Rajeev Bansal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).