[llvm-dev] diagnose_if attribute not working as described
Roger Pau Monné via llvm-dev
llvm-dev at lists.llvm.org
Thu May 28 08:09:50 PDT 2020
Hello,
I'm trying to use the diagnose_if to prevent function calls to certain
symbols. The documentation for diagnose_if states: "The diagnose_if
attribute can be placed on function declarations to emit warnings or
errors at compile-time if calls to the attributed function meet
certain user-defined criteria."
Yet the following example fails to compile:
#define nocall __attribute__((diagnose_if(1, "Nonstandard ABI", "error")))
void nocall foo(void);
void bar(void)
{
#define FOOBAR(f) ({ void *t = f; })
FOOBAR(foo);
#undef FOOBAR
}
<source>:8:12: error: Nonstandard ABI
FOOBAR(foo);
^
<source>:3:6: note: from 'diagnose_if' attribute on 'foo':
void nocall foo(void);
^~~~~~
<source>:1:31: note: expanded from macro 'nocall'
#define nocall __attribute__((diagnose_if(1, "Nonstandard ABI", "error")))
^ ~
1 error generated.
Yet the example doesn't make any call to foo, and hence the
documentation should be fixed to state that any usage of the function
will trigger the diagnose?
Or is there some way to force diagnose_if to apply strictly to
function calls only?
Thanks, Roger.
More information about the llvm-dev
mailing list