Skip to content

Commit a56f762

Browse files
committed
Fix build against GCC 4.8
1 parent 950a0ba commit a56f762

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

gcc-c-api/gcc-callgraph.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
#include "ggc.h"
2424
#include "tree-ssa-alias.h"
2525
#include "basic-block.h"
26+
#if (GCC_VERSION >= 5000)
2627
#include "gimple-expr.h"
28+
#endif
2729
#include "gimple.h"
2830

2931
/***********************************************************

gcc-python-pass.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,20 @@ class PyGccSimpleIpaPass : public simple_ipa_opt_pass
254254
opt_pass *clone() {return this; }
255255
};
256256

257-
#endif /* #if (GCC_VERSION >= 4009) */
257+
#else /* #if (GCC_VERSION >= 4009) */
258+
/*
259+
Before GCC 4.9, passes were implemented using callback functions.
260+
*/
261+
static bool gate_cb(void)
262+
{
263+
return impl_gate(cfun);
264+
}
265+
266+
static unsigned int execute_cb(void)
267+
{
268+
return impl_execute(cfun);
269+
}
270+
#endif /* #else clause of if (GCC_VERSION >= 4009) */
258271

259272
static int
260273
do_pass_init(PyObject *s, PyObject *args, PyObject *kwargs,
@@ -303,7 +316,7 @@ do_pass_init(PyObject *s, PyObject *args, PyObject *kwargs,
303316
default:
304317
gcc_unreachable();
305318
}
306-
#else
319+
#else /* #if (GCC_VERSION >= 4009) */
307320
pass = (struct opt_pass*)PyMem_Malloc(sizeof_pass);
308321
if (!pass) {
309322
return -1;
@@ -321,9 +334,9 @@ do_pass_init(PyObject *s, PyObject *args, PyObject *kwargs,
321334
return -1;
322335
}
323336

324-
pass->gate = impl_gate;
325-
pass->execute = impl_execute;
326-
#endif
337+
pass->gate = gate_cb;
338+
pass->execute = execute_cb;
339+
#endif /* ending the #else clause of #if (GCC_VERSION >= 4009) */
327340

328341
if (PyGcc_insert_new_wrapper_into_cache(&pass_wrapper_cache,
329342
pass,

0 commit comments

Comments
 (0)