Home | History | Annotate | Download | only in tests
      1 #include <stdio.h>
      2 #include "../memcheck.h"
      3 #define INLINE    inline __attribute__((always_inline))
      4 
      5 INLINE int fun_d(int argd) {
      6    static int locd = 0;
      7    if (argd > 0)
      8       locd += argd;
      9    return locd;
     10 }
     11 
     12 INLINE int fun_c(int argc) {
     13    static int locc = 0;
     14    locc += argc;
     15    return fun_d(locc);
     16 }
     17 
     18 INLINE int fun_b(int argb) {
     19    static int locb = 0;
     20    locb += argb;
     21    return fun_c(locb);
     22 }
     23 
     24 INLINE int fun_a(int arga) {
     25    static int loca = 0;
     26    loca += arga;
     27    return fun_b(loca);
     28 }
     29 
     30 __attribute__((noinline))
     31 static int fun_noninline_m(int argm)
     32 {
     33    return fun_d(argm);
     34 }
     35 
     36 __attribute__((noinline))
     37 static int fun_noninline_o(int argo)
     38 {
     39    static int loco = 0;
     40    if (argo > 0)
     41       loco += argo;
     42    return loco;
     43 }
     44 
     45 INLINE int fun_f(int argf) {
     46    static int locf = 0;
     47    locf += argf;
     48    return fun_noninline_o(locf);
     49 }
     50 
     51 INLINE int fun_e(int arge) {
     52    static int loce = 0;
     53    loce += arge;
     54    return fun_f(loce);
     55 }
     56 
     57 __attribute__((noinline))
     58 static int fun_noninline_n(int argn)
     59 {
     60    return fun_e(argn);
     61 }
     62 
     63 
     64 int main() {
     65    int result;
     66    result = fun_a(result);
     67    VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result));
     68    result += fun_noninline_m(result);
     69    VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result));
     70    result += fun_d(result);
     71    VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result));
     72    result += fun_noninline_n(result);
     73    return 0;
     74 }
     75 
     76