aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Frontend/backend-attribute-error-warning-optimize.c
blob: d5a8d57e36c9640dd5782f90fb39a0cdb2fd861b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// 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();
}

// https://github.com/llvm/llvm-project/issues/146520

[[gnu::error("error please")]]
void cleaner_function(char*);

void asdf(void){
	[[gnu::cleanup(cleaner_function)]] // expected-error {{call to 'cleaner_function' declared with 'error' attribute: error please}}
	char x; 
}