1 #include "check_debug.h"
   2 
   3 int a, b, c;
   4 int func(void)
   5 {
   6         if (a ? b : c)
   7                 __smatch_value("a");
   8 
   9         __smatch_note("Test #1 a ? 1 : c");
  10         if (a ? 1 : c) {        
  11                 __smatch_value("a");
  12                 __smatch_value("c");
  13                 if (!a)
  14                         __smatch_value("c");
  15                 if (!c)
  16                         __smatch_value("a");
  17         } else {
  18                 __smatch_value("a");
  19                 __smatch_value("c");
  20         }
  21 
  22         __smatch_note("Test #2 a ? 0 : c");
  23         if (a ? 0 : c) {        
  24                 __smatch_value("a");
  25                 __smatch_value("c");
  26                 if (!a)
  27                         __smatch_value("c");
  28         } else {
  29                 __smatch_value("a");
  30                 __smatch_value("c");
  31                 if (!a)
  32                         __smatch_value("c");
  33                 if (!c)
  34                         __smatch_value("a");
  35         }
  36 
  37         __smatch_note("Test #3 a ? b : 1");
  38         if (a ? b : 1) {        
  39                 __smatch_value("a");
  40                 __smatch_value("b");
  41                 if (!a)
  42                         __smatch_value("b");
  43                 if (!b)
  44                         __smatch_value("a");
  45         } else {
  46                 __smatch_value("a");
  47                 __smatch_value("b");
  48                 if (!b)
  49                         __smatch_value("a");
  50         }
  51 
  52         __smatch_note("Test #2 a ? b : 0");
  53         if (a ? b : 0) {        
  54                 __smatch_value("a");
  55                 __smatch_value("b");
  56         } else {
  57                 __smatch_value("a");
  58                 __smatch_value("b");
  59                 if (a)
  60                         __smatch_value("b");
  61                 if (b)
  62                         __smatch_value("a");
  63         }
  64 }
  65 
  66 
  67 /*
  68  * check-name: Ternary Conditions #3
  69  * check-command: smatch -I.. sm_select3.c
  70  *
  71  * check-output-start
  72 sm_select3.c:7 func() a = s32min-s32max
  73 sm_select3.c:9 func() Test #1 a ? 1 : c
  74 sm_select3.c:11 func() a = s32min-s32max
  75 sm_select3.c:12 func() c = s32min-s32max
  76 sm_select3.c:14 func() c = s32min-(-1),1-s32max
  77 sm_select3.c:16 func() a = s32min-(-1),1-s32max
  78 sm_select3.c:18 func() a = 0
  79 sm_select3.c:19 func() c = 0
  80 sm_select3.c:22 func() Test #2 a ? 0 : c
  81 sm_select3.c:24 func() a = 0
  82 sm_select3.c:25 func() c = s32min-(-1),1-s32max
  83 sm_select3.c:27 func() c = s32min-(-1),1-s32max
  84 sm_select3.c:29 func() a = s32min-s32max
  85 sm_select3.c:30 func() c = s32min-s32max
  86 sm_select3.c:32 func() c = 0
  87 sm_select3.c:34 func() a = s32min-s32max
  88 sm_select3.c:37 func() Test #3 a ? b : 1
  89 sm_select3.c:39 func() a = s32min-s32max
  90 sm_select3.c:40 func() b = s32min-s32max
  91 sm_select3.c:42 func() b = s32min-s32max
  92 sm_select3.c:44 func() a = 0
  93 sm_select3.c:46 func() a = s32min-(-1),1-s32max
  94 sm_select3.c:47 func() b = 0
  95 sm_select3.c:49 func() a = s32min-(-1),1-s32max
  96 sm_select3.c:52 func() Test #2 a ? b : 0
  97 sm_select3.c:54 func() a = s32min-(-1),1-s32max
  98 sm_select3.c:55 func() b = s32min-(-1),1-s32max
  99 sm_select3.c:57 func() a = s32min-s32max
 100 sm_select3.c:58 func() b = s32min-s32max
 101 sm_select3.c:60 func() b = 0
 102 sm_select3.c:62 func() a = 0
 103  * check-output-end
 104  */