llvm-capstone/clang/test/Frontend/backend-attribute-error-warning-optimize.c
Arthur Eubanks 2943071e2e [clang] Rework dontcall attributes
To avoid using the AST when emitting diagnostics, split the "dontcall"
attribute into "dontcall-warn" and "dontcall-error", and also add the
frontend attribute value as the LLVM attribute value. This gives us all
the information to report diagnostics we need from within the IR (aside
from access to the original source).

One downside is we directly use LLVM's demangler rather than using the
existing Clang diagnostic pretty printing of symbols.

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D110364
2021-09-28 14:21:10 -07:00

23 lines
447 B
C

// RUN: %clang_cc1 -O2 -verify -emit-codegen-only %s
__attribute__((error("oh no foo"))) void foo(void);
__attribute__((error("oh no bar"))) void bar(void);
int x(void) {
return 8 % 2 == 1;
}
void baz(void) {
foo(); // expected-error {{call to foo declared with 'error' attribute: oh no foo}}
if (x())
bar();
}
// FIXME: indirect call detection not yet supported.
void (*quux)(void);
void indirect(void) {
quux = foo;
quux();
}