[NDS32] Add intrinsic functions for TLB operation and data prefech.
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-37.c
blob865653c18d3410da25fc9973e01ddfca562ce755
1 /* PR tree-optimization/78450 - strlen(s) return value can be assumed
2 to be less than the size of s
3 { dg-do compile }
4 { dg-options "-O2 -fdump-tree-optimized" } */
6 #include "strlenopt.h"
8 extern char ax[];
10 struct MemArray7 { char a7[7]; };
11 struct MemArray6 { char a6[6]; };
12 struct MemArray5 { char a5[5]; };
13 struct MemArray4 { char a4[4]; };
14 struct MemArray3 { char a3[3]; };
15 struct MemArray2 { char a2[2]; };
16 struct MemArray1 { char a1[1]; };
17 struct MemArray0 { int n; char a0[0]; };
18 struct MemArrayX { int n; char ax[]; };
20 struct MemArrays
22 struct MemArray7 *ma7;
23 struct MemArray6 *ma6;
24 struct MemArray5 *ma5;
25 struct MemArray4 *ma4;
26 struct MemArray3 *ma3;
27 struct MemArray2 *ma2;
28 struct MemArray1 *ma1;
29 struct MemArray0 *ma0;
30 struct MemArrayX *max;
33 extern void if_stmt_on_line (int);
34 extern void else_stmt_on_line (int);
36 #define T(expr) \
37 (!!(expr) ? if_stmt_on_line (__LINE__) : else_stmt_on_line (__LINE__))
39 void test_memarray_lt (struct MemArrays *p)
41 T (strlen (p->ma7->a7) < sizeof p->ma7->a7);
42 T (strlen (p->ma6->a6) < sizeof p->ma6->a6);
43 T (strlen (p->ma5->a5) < sizeof p->ma5->a5);
44 T (strlen (p->ma4->a4) < sizeof p->ma4->a4);
45 T (strlen (p->ma3->a3) < sizeof p->ma3->a3);
46 T (strlen (p->ma2->a2) < sizeof p->ma2->a2);
47 T (strlen (p->ma1->a1) < sizeof p->ma1->a1);
49 T (strlen (p->ma0->a0) < 1);
50 T (strlen (p->max->ax) < 1);
53 void test_memarray_eq (struct MemArrays *p)
55 T (strlen (p->ma7->a7) == sizeof p->ma7->a7);
56 T (strlen (p->ma6->a6) == sizeof p->ma6->a6);
57 T (strlen (p->ma5->a5) == sizeof p->ma5->a5);
58 T (strlen (p->ma4->a4) == sizeof p->ma4->a4);
59 T (strlen (p->ma3->a3) == sizeof p->ma3->a3);
60 T (strlen (p->ma2->a2) == sizeof p->ma2->a2);
61 T (strlen (p->ma1->a1) == sizeof p->ma1->a1);
63 T (strlen (p->ma0->a0) == 1);
64 T (strlen (p->max->ax) == 1);
67 void test_memarray_gt (struct MemArrays *p)
69 T (strlen (p->ma7->a7) > sizeof p->ma7->a7);
70 T (strlen (p->ma6->a6) > sizeof p->ma6->a6);
71 T (strlen (p->ma5->a5) > sizeof p->ma5->a5);
72 T (strlen (p->ma4->a4) > sizeof p->ma4->a4);
73 T (strlen (p->ma3->a3) > sizeof p->ma3->a3);
74 T (strlen (p->ma2->a2) > sizeof p->ma2->a2);
75 T (strlen (p->ma1->a1) > sizeof p->ma1->a1);
77 T (strlen (p->ma0->a0) > 1);
78 T (strlen (p->max->ax) > 1);
81 /* Verify that no if or else statements have been eliminated.
82 { dg-final { scan-tree-dump-times "if_stmt_on_line" 27 "optimized" } }
83 { dg-final { scan-tree-dump-times "else_stmt_on_line" 27 "optimized" } } */