view gcc/testsuite/gcc.dg/strlenopt-48.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children 1830386684a0
line wrap: on
line source

/* PR tree-optimization/86400 - set<string>::set<char (*)[2]) constructor
   does not work with array argument
   Verify that strlen() calls with one-character array elements of
   multidimensional arrays are still folded.
   { dg-do compile }
   { dg-options "-O2 -Wall -fdump-tree-optimized" } */

#include "strlenopt.h"

void f (void)
{
  extern char a[2][1];
  int n = strlen (a[1]);
  if (n)
    abort();
}

void g (void)
{
  extern char b[3][2][1];
  int n = strlen (b[2][1]);
  if (n)
    abort();
}

void h (void)
{
  extern char c[4][3][2][1];
  int n = strlen (c[3][2][1]);
  if (n)
    abort();
}

/* { dg-final { scan-tree-dump-times "strlen" 0 "optimized" } }
   { dg-final { scan-tree-dump-times "abort" 0 "optimized" } } */