Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/gcc.dg/pr79715.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* PR tree-optimization/79715 - hand-rolled strdup with unused result | |
2 not eliminated | |
3 { dg-do compile } | |
4 { dg-options "-O2 -Wall -fdump-tree-optimized" } */ | |
5 | |
6 void f (const char *s) | |
7 { | |
8 unsigned n = __builtin_strlen (s) + 1; | |
9 char *p = __builtin_malloc (n); | |
10 __builtin_memcpy (p, s, n); | |
11 __builtin_free (p); | |
12 } | |
13 | |
14 void g (const char *s) | |
15 { | |
16 unsigned n = __builtin_strlen (s) + 1; | |
17 char *p = __builtin_malloc (n); | |
18 __builtin_strcpy (p, s); | |
19 __builtin_free (p); | |
20 } | |
21 | |
22 /* { dg-final { scan-tree-dump-not "free" "optimized" } } | |
23 { dg-final { scan-tree-dump-not "malloc" "optimized" } } | |
24 { dg-final { scan-tree-dump-not "memcpy" "optimized" } } | |
25 { dg-final { scan-tree-dump-not "strcpy" "optimized" } } | |
26 { dg-final { scan-tree-dump-not "strlen" "optimized" } } */ |