summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/strcmpopt_1.c
blob: b1e0bc3b274ed6bd3e0c4ed874506d39c9be5d90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* { dg-do run } */
/* { dg-options "-fdump-tree-lower" } */

#include <string.h>
#include <stdlib.h>

int cmp1 (char *p)
{
  return strncmp (p, "fis", 4);
}
int cmp2 (char *q)
{
  return strncmp ("fis", q, 4);
}

int main ()
{

  char *p = "fish";
  char *q = "fis\0";

  if (cmp1 (p) == 0 || cmp2 (q) != 0)
    abort ();

  return 0;
}

/* { dg-final { scan-tree-dump-times "strcmp \\(" 2 "lower" } } */