1 // Test that misexpect emits no warning when switch condition is non-const
3 // RUN: llvm-profdata merge %S/Inputs/misexpect-switch-nonconst.proftext -o %t.profdata
4 // RUN: %clang_cc1 %s -O2 -o - -disable-llvm-passes -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify
6 // expected-no-diagnostics
8 #define inner_loop 1000
12 int sum(int *buff
, int size
);
13 int random_sample(int *buff
, int size
);
17 int arry
[arry_size
] = {0};
24 for (j
= 0; j
< outer_loop
; ++j
) {
25 for (k
= 0; k
< inner_loop
; ++k
) {
26 unsigned condition
= rand() % 10000;
27 switch (__builtin_expect(condition
, rand())) {
29 val
+= sum(arry
, arry_size
);
35 val
+= random_sample(arry
, arry_size
);
38 __builtin_unreachable();