1 /*
2    pr20527-1.c from the execute part of the gcc torture tests.
3  */
4 
5 #include <testfwk.h>
6 
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
10 
11 /* PR rtl-optimization/20527
12    Mishandled postincrement.  This test-case is derived from the
13    function BZ2_hbCreateDecodeTables in the file huffman.c from
14    bzip2-1.0.2, hence requiring the following disclaimer copied here:  */
15 
16 /*--
17   This file is a part of bzip2 and/or libbzip2, a program and
18   library for lossless, block-sorting data compression.
19 
20   Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.
21 
22   Redistribution and use in source and binary forms, with or without
23   modification, are permitted provided that the following conditions
24   are met:
25 
26   1. Redistributions of source code must retain the above copyright
27      notice, this list of conditions and the following disclaimer.
28 
29   2. The origin of this software must not be misrepresented; you must
30      not claim that you wrote the original software.  If you use this
31      software in a product, an acknowledgment in the product
32      documentation would be appreciated but is not required.
33 
34   3. Altered source versions must be plainly marked as such, and must
35      not be misrepresented as being the original software.
36 
37   4. The name of the author may not be used to endorse or promote
38      products derived from this software without specific prior written
39      permission.
40 
41   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
42   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
43   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
45   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
47   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
48   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
49   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
50   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
51   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 
53   Julian Seward, Cambridge, UK.
54   jseward@acm.org
55   bzip2/libbzip2 version 1.0 of 21 March 2000
56 
57   This program is based on (at least) the work of:
58      Mike Burrows
59      David Wheeler
60      Peter Fenwick
61      Alistair Moffat
62      Radford Neal
63      Ian H. Witten
64      Robert Sedgewick
65      Jon L. Bentley
66 
67   For more information on these sources, see the manual.
68 --*/
69 
70 #if !defined(__SDCC_pdk14) // Lack of memory
71 void f (long *limit, long *base, long minLen, long maxLen);
f(long * limit,long * base,long minLen,long maxLen)72 void f (long *limit, long *base, long minLen, long maxLen)
73 {
74   long i;
75   long vec;
76   vec = 0;
77   for (i = minLen; i <= maxLen; i++) {
78     vec += (base[i+1] - base[i]);
79     limit[i] = vec-1;
80   }
81 }
82 
83 long b[] = {1, 5, 11, 23};
84 #endif
85 
86 void
testTortureExecute(void)87 testTortureExecute (void)
88 {
89 #if !defined(__SDCC_pdk14) // Lack of memory
90   long l[3];
91   f (l, b, 0, 2);
92   if (l[0] != 3 || l[1] != 9 || l[2] != 21)
93     ASSERT (0);
94   return;
95 #endif
96 }
97 
98