PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-47.c
blob68945c7c1a19c67c49ca1c97fd549c749d70fcff
1 /* PR tree-optimization/86400 - set<string>::set<char (*)[2]) constructor
2 does not work with array argument
3 Verify that strlen() calls with two-character array elements of
4 multidimensional arrays whose higher order dimension is 1 are not
5 folded.
6 { dg-do compile }
7 { dg-options "-O2 -Wall -fdump-tree-optimized" } */
9 #include "strlenopt.h"
11 void f (void)
13 extern char a[1][2];
14 int n = strlen (*a);
15 if (n != 1)
16 abort();
19 void g (void)
21 extern char b[1][2];
22 int n = strlen (b[0]);
23 if (n != 1)
24 abort();
27 void h (void)
29 extern char c[1][2];
30 int n = strlen (&c[0][0]);
31 if (n != 1)
32 abort();
35 /* { dg-final { scan-tree-dump-times "= strlen" 3 "optimized" } }
36 { dg-final { scan-tree-dump-times "abort" 3 "optimized" } } */