aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Sema/warn-alloca.c
blob: 07fe0f920304da533c427022bac58753c504023d (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
33
34
// RUN: %clang_cc1 -DSILENCE -fsyntax-only -verify -Wall %s
// RUN: %clang_cc1 -fsyntax-only -verify -Walloca %s

#ifdef SILENCE
  // expected-no-diagnostics
#endif

void test1(int a) {
  __builtin_alloca(a);
#ifndef SILENCE
  // expected-warning@-2 {{use of function '__builtin_alloca' is discouraged; there is no way to check for failure but failure may still occur, resulting in a possibly exploitable security vulnerability}}
#endif
}

void test2(int a) {
  __builtin_alloca_with_align(a, 32);
#ifndef SILENCE
  // expected-warning@-2 {{use of function '__builtin_alloca_with_align' is discouraged; there is no way to check for failure but failure may still occur, resulting in a possibly exploitable security vulnerability}}
#endif
}

void test3(int a) {
  __builtin_alloca_uninitialized(a);
#ifndef SILENCE
  // expected-warning@-2 {{use of function '__builtin_alloca_uninitialized' is discouraged; there is no way to check for failure but failure may still occur, resulting in a possibly exploitable security vulnerability}}
#endif
}

void test4(int a) {
  __builtin_alloca_with_align_uninitialized(a, 32);
#ifndef SILENCE
  // expected-warning@-2 {{use of function '__builtin_alloca_with_align_uninitialized' is discouraged; there is no way to check for failure but failure may still occur, resulting in a possibly exploitable security vulnerability}}
#endif
}