This exposes the GCC 'inform' function as gcc.inform.
Tom
diff --git a/docs/basics.rst b/docs/basics.rst
index d51947b..2c9b344 100644
--- a/docs/basics.rst
+++ b/docs/basics.rst
@@ -429,6 +429,25 @@ Generating custom errors and warnings
Returns True if the warning was actually printed, False otherwise
+.. py:function:: gcc.inform(loc, str)
+
+ This is a wrapper around GCC's `inform` function.
+
+ Expects an instance of :py:class:`gcc.Location` (not None) and a string
+
+ Emit an informational message at that location.
+
+ For example::
+
+ gcc.inform(stmt.loc, 'this is where X was defined')
+
+ would lead to this informational message being printed:
+
+ .. code-block:: bash
+
+ $ ./gcc-with-python script.py input.c
+ input.c:23:3: note: this is where X was defined
+
Global data access
==================
diff --git a/gcc-python.c b/gcc-python.c
index 4e35456..79262ab 100644
--- a/gcc-python.c
+++ b/gcc-python.c
@@ -373,6 +373,27 @@ gcc_python_warning(PyObject *self, PyObject *args, PyObject *kwargs)
}
static PyObject *
+gcc_python_inform(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ PyGccLocation *loc_obj;
+ const char *msg;
+ char *keywords[] = {"location",
+ "message",
+ NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!s:inform", keywords,
+ &gcc_LocationType, &loc_obj,
+ &msg)) {
+ return NULL;
+ }
+
+ inform(loc_obj->loc, "%s", msg);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
gcc_python_get_option_list(PyObject *self, PyObject *args)
{
PyObject *result;
@@ -533,6 +554,11 @@ static PyMethodDef GccMethods[] = {
(METH_VARARGS | METH_KEYWORDS),
("Report a warning\n"
"FIXME\n")},
+ {"inform",
+ (PyCFunction)gcc_python_inform,
+ (METH_VARARGS | METH_KEYWORDS),
+ ("Report an information message\n"
+ "FIXME\n")},
/* Options: */
{"get_option_list",
Show replies by date