Home | History | Annotate | Line # | Download | only in lint1
d_fold_test.c revision 1.2
      1 # 2 "d_fold_test.c"
      2 
      3 /*
      4  * Test how expressions are handled in a context where they are tested for
      5  * truthiness, such as in the condition of an if statement.
      6  */
      7 
      8 struct s {
      9 	int member;
     10 };
     11 
     12 union u {
     13 	int member;
     14 };
     15 
     16 enum e {
     17 	E
     18 };
     19 
     20 struct arr {
     21 	int arr[4];
     22 };
     23 
     24 /* C99 6.2.5p2 */
     25 void if_Bool(_Bool b)			{ if (b) return; }
     26 
     27 /* C99 6.2.5p3 */
     28 void if_char(char c)			{ if (c) return; }
     29 
     30 /* C99 6.2.5p4 */
     31 void if_signed_char(signed char sc)	{ if (sc) return; }
     32 void if_short_int(short s)		{ if (s) return; }
     33 void if_int(int i)			{ if (i) return; }
     34 void if_long_int(long int l)		{ if (l) return; }
     35 void if_long_long_int(long long int ll)	{ if (ll) return; }
     36 
     37 /* C99 6.2.5p6 */
     38 void if_unsigned_char(unsigned char uc)			{ if (uc) return; }
     39 void if_unsigned_short_int(unsigned short us)		{ if (us) return; }
     40 void if_unsigned_int(unsigned int ui)			{ if (ui) return; }
     41 void if_unsigned_long_int(unsigned long int ul)		{ if (ul) return; }
     42 void if_unsigned_long_long_int(unsigned long long int ull) { if (ull) return; }
     43 
     44 /* C99 6.2.5p10 */
     45 void if_float(float f)			{ if (f) return; }
     46 void if_double(double d)		{ if (d) return; }
     47 void if_long_double(long double ld)	{ if (ld) return; }
     48 
     49 /* C99 6.2.5p11 */
     50 void if_float_Complex(float _Complex fc)		{ if (fc) return; }
     51 void if_double_Complex(double _Complex dc)		{ if (dc) return; }
     52 void if_long_double_Complex(long double _Complex ldc)	{ if (ldc) return; }
     53 
     54 /* C99 6.2.5p16 */
     55 void if_enum(enum e e)			{ if (e) return; }
     56 
     57 /* C99 6.2.5p20 */
     58 void if_array(struct arr arr)		{ if (arr.arr) return; }
     59 void if_struct(struct s s)		{ if (s) return; }
     60 void if_union(union u u)		{ if (u) return; }
     61 void if_function(void)			{ if (if_function) return; }
     62 void if_pointer(void *p)		{ if (p) return; }
     63 
     64 /* C99 6.8.5 */
     65 void while_struct(struct s s)		{ while (s) return; }
     66 void for_struct(struct s s)		{ for (;s;) return; }
     67 void do_while_struct(struct s s)	{ do { return; } while (s); }
     68 
     69 /* C99 6.5.15 does not require a scalar type, curiously. */
     70 int conditional_struct(struct s s)	{ return s ? 1 : 2; }
     71