This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Don't require -DIN_GCC while compiling plugins
- From: Rafael Espindola <espindola at google dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Diego Novillo <dnovillo at google dot com>
- Date: Tue, 26 May 2009 11:20:23 +0100
- Subject: [patch] Don't require -DIN_GCC while compiling plugins
Currently a user must pass -DIN_GCC when compiling plugins out of
tree. This is an unusual interface. It is more common to have all
necessary definitions in a header file that is included first.
Currently gcc-plugin.h almost fits the bill. The only issue is one use
of bool and the need to define IN_GCC. This patch fixes this by
changing the bool to int and defining IN_GCC if it was not defined
before.
The patch also updates the plugins in the testsuite to include
gcc-plugin.h first.
2009-05-26 Rafael Avila de Espindola <espindola@google.com>
* gcc-plugin.h (IN_GCC) Define if not defined.
(plugin_default_version_check): Return int.
* plugin.c (plugin_default_version_check): Return int.
2009-05-26 Rafael Avila de Espindola <espindola@google.com>
* g++.dg/plugin/attribute_plugin.c: Include gcc-plugin.h first.
* g++.dg/plugin/dumb_plugin.c: Include gcc-plugin.h first.
* g++.dg/plugin/selfassign.c: Include gcc-plugin.h first.
* gcc.dg/plugin/selfassign.c: Include gcc-plugin.h first.
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/gcc/gcc-plugin.h b/gcc/gcc-plugin.h
index e788eb7..232f5ef 100644
--- a/gcc/gcc-plugin.h
+++ b/gcc/gcc-plugin.h
@@ -20,6 +20,10 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_PLUGIN_H
#define GCC_PLUGIN_H
+#ifndef IN_GCC
+#define IN_GCC
+#endif
+
/* Event names. Keep in sync with plugin_event_name[]. */
enum plugin_event
{
@@ -95,8 +99,8 @@ struct plugin_name_args
/* The default version check. Compares every field in VERSION. */
-extern bool plugin_default_version_check (struct plugin_gcc_version *,
- struct plugin_gcc_version *);
+extern int plugin_default_version_check (struct plugin_gcc_version *,
+ struct plugin_gcc_version *);
/* Function type for the plugin initialization routine. Each plugin module
should define this as an externally-visible function with name
diff --git a/gcc/plugin.c b/gcc/plugin.c
index 6cee526..e41fbbd 100644
--- a/gcc/plugin.c
+++ b/gcc/plugin.c
@@ -800,23 +800,23 @@ debug_active_plugins (void)
/* The default version check. Compares every field in VERSION. */
-bool
+int
plugin_default_version_check (struct plugin_gcc_version *gcc_version,
struct plugin_gcc_version *plugin_version)
{
if (!gcc_version || !plugin_version)
- return false;
+ return 0;
if (strcmp (gcc_version->basever, plugin_version->basever))
- return false;
+ return 0;
if (strcmp (gcc_version->datestamp, plugin_version->datestamp))
- return false;
+ return 0;
if (strcmp (gcc_version->devphase, plugin_version->devphase))
- return false;
+ return 0;
if (strcmp (gcc_version->revision, plugin_version->revision))
- return false;
+ return 0;
if (strcmp (gcc_version->configuration_arguments,
plugin_version->configuration_arguments))
- return false;
- return true;
+ return 0;
+ return 1;
}
diff --git a/gcc/testsuite/g++.dg/plugin/attribute_plugin.c b/gcc/testsuite/g++.dg/plugin/attribute_plugin.c
index 2624ea2..16b3496 100644
--- a/gcc/testsuite/g++.dg/plugin/attribute_plugin.c
+++ b/gcc/testsuite/g++.dg/plugin/attribute_plugin.c
@@ -1,5 +1,6 @@
/* Demonstrates how to add custom attributes */
+#include "gcc-plugin.h"
#include <stdlib.h>
#include "config.h"
#include "system.h"
@@ -7,7 +8,6 @@
#include "tree.h"
#include "tree-pass.h"
#include "intl.h"
-#include "gcc-plugin.h"
/* Attribute handler callback */
diff --git a/gcc/testsuite/g++.dg/plugin/dumb_plugin.c b/gcc/testsuite/g++.dg/plugin/dumb_plugin.c
index 81e68eb..24da544 100644
--- a/gcc/testsuite/g++.dg/plugin/dumb_plugin.c
+++ b/gcc/testsuite/g++.dg/plugin/dumb_plugin.c
@@ -1,6 +1,7 @@
/* A trivial (dumb) plugin example that shows how to use the GCC plugin
mechanism. */
+#include "gcc-plugin.h"
#include <stdlib.h>
#include "config.h"
#include "system.h"
@@ -8,7 +9,6 @@
#include "tree.h"
#include "tree-pass.h"
#include "intl.h"
-#include "gcc-plugin.h"
/* Callback function to invoke after GCC finishes parsing a struct. */
diff --git a/gcc/testsuite/g++.dg/plugin/selfassign.c b/gcc/testsuite/g++.dg/plugin/selfassign.c
index 9e7e84c..2bc1d86 100644
--- a/gcc/testsuite/g++.dg/plugin/selfassign.c
+++ b/gcc/testsuite/g++.dg/plugin/selfassign.c
@@ -2,6 +2,7 @@
self-assignment statements. */
/* { dg-options "-O" } */
+#include "gcc-plugin.h"
#include "config.h"
#include "system.h"
#include "coretypes.h"
@@ -12,7 +13,6 @@
#include "tree.h"
#include "tree-pass.h"
#include "intl.h"
-#include "gcc-plugin.h"
/* Indicate whether to check overloaded operator '=', which is performed by
diff --git a/gcc/testsuite/gcc.dg/plugin/selfassign.c b/gcc/testsuite/gcc.dg/plugin/selfassign.c
index 9e7e84c..2bc1d86 100644
--- a/gcc/testsuite/gcc.dg/plugin/selfassign.c
+++ b/gcc/testsuite/gcc.dg/plugin/selfassign.c
@@ -2,6 +2,7 @@
self-assignment statements. */
/* { dg-options "-O" } */
+#include "gcc-plugin.h"
#include "config.h"
#include "system.h"
#include "coretypes.h"
@@ -12,7 +13,6 @@
#include "tree.h"
#include "tree-pass.h"
#include "intl.h"
-#include "gcc-plugin.h"
/* Indicate whether to check overloaded operator '=', which is performed by