Fix skip.exp test failure observed with gcc-9.2.0
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / run.c
... / ...
CommitLineData
1/*
2 * This simple classical example of recursion is useful for
3 * testing stack backtraces and such.
4 */
5
6#include <stdio.h>
7#include <stdlib.h>
8
9#include "../lib/unbuffer_output.c"
10
11int factorial (int);
12
13int
14main (int argc, char **argv, char **envp)
15{
16 gdb_unbuffer_output ();
17
18#ifdef FAKEARGV
19 printf ("%d\n", factorial (1)); /* commands.exp: hw local_var out of scope */
20#else
21 if (argc != 2) {
22 printf ("usage: factorial <number>\n");
23 return 1;
24 } else {
25 printf ("%d\n", factorial (atoi (argv[1])));
26 }
27#endif
28 return 0;
29}
30
31int factorial (int value)
32{
33 int local_var;
34
35 if (value > 1) {
36 value *= factorial (value - 1);
37 }
38 local_var = value;
39 return (value);
40} /* commands.exp: local_var out of scope */
This page took 0.02194 seconds and 4 git commands to generate.