1 1.11 christos /* Copyright (C) 2008-2024 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos This program is free software; you can redistribute it and/or modify 4 1.1 christos it under the terms of the GNU General Public License as published by 5 1.1 christos the Free Software Foundation; either version 3 of the License, or 6 1.1 christos (at your option) any later version. 7 1.1 christos 8 1.1 christos This program is distributed in the hope that it will be useful, 9 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos GNU General Public License for more details. 12 1.1 christos 13 1.1 christos You should have received a copy of the GNU General Public License 14 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 1.1 christos 16 1.1 christos /* This is only ever run if it is compiled with a new-enough GCC, but 17 1.1 christos we don't want the compilation to fail if compiled by some other 18 1.1 christos compiler. */ 19 1.1 christos #ifdef __GNUC__ 20 1.1 christos #define ATTR __attribute__((always_inline)) 21 1.1 christos #else 22 1.1 christos #define ATTR 23 1.1 christos #endif 24 1.1 christos 25 1.1 christos int x, y; 26 1.6 christos volatile int z = 0; 27 1.1 christos volatile int result; 28 1.1 christos volatile int *array_p; 29 1.1 christos 30 1.1 christos void bar(void); 31 1.1 christos 32 1.9 christos void 33 1.9 christos init_array (int *array, int n) 34 1.9 christos { 35 1.9 christos int i; 36 1.9 christos for (i = 0; i < n; ++i) 37 1.9 christos array[i] = 0; 38 1.9 christos } 39 1.9 christos 40 1.1 christos inline ATTR int func1(int arg1) 41 1.1 christos { 42 1.1 christos int array[64]; 43 1.9 christos init_array (array, 64); 44 1.1 christos array_p = array; 45 1.1 christos array[0] = result; 46 1.1 christos array[1] = arg1; 47 1.1 christos bar (); 48 1.1 christos return x * y + array_p[0] * arg1; 49 1.1 christos } 50 1.1 christos 51 1.1 christos inline ATTR int func2(int arg2) 52 1.1 christos { 53 1.1 christos return x * func1 (arg2); 54 1.1 christos } 55 1.1 christos 56 1.10 christos inline ATTR 57 1.10 christos void 58 1.10 christos scoped (int s) 59 1.10 christos { 60 1.10 christos int loc1 = 10; 61 1.10 christos if (s > 0) 62 1.10 christos { 63 1.10 christos int loc2 = 20; 64 1.10 christos s++; /* bp for locals 1 */ 65 1.10 christos if (s > 1) 66 1.10 christos { 67 1.10 christos int loc3 = 30; 68 1.10 christos s++; /* bp for locals 2 */ 69 1.10 christos } 70 1.10 christos } 71 1.10 christos s++; /* bp for locals 3 */ 72 1.10 christos } 73 1.10 christos 74 1.1 christos int main (void) 75 1.1 christos { 76 1.1 christos int val; 77 1.1 christos 78 1.1 christos x = 7; 79 1.1 christos y = 8; 80 1.1 christos bar (); 81 1.1 christos 82 1.1 christos val = func1 (result); 83 1.1 christos result = val; 84 1.1 christos 85 1.1 christos val = func2 (result); 86 1.1 christos result = val; 87 1.1 christos 88 1.10 christos scoped (40); 89 1.10 christos 90 1.1 christos return 0; 91 1.1 christos } 92