From patchwork Tue Jun 8 12:36:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: RFC: Fix plugins/44459 2/2 Date: Tue, 08 Jun 2010 02:36:50 -0000 From: Joern Rennecke X-Patchwork-Id: 54967 Message-Id: <20100608083650.sznjdqd6k4kwgggc-nzlynne@webmail.spamcop.net> To: gcc-patches@gcc.gnu.org This is the second part of the patch set to fix PR44459, which adds extern "C" linkage to a few very common functions that are used in the plugin tests of the gcc testsuite. If more, or less, or any of these should be included, might be subject to debate. Bootstrapped and regression tested in 160389 with --enable-build-with-cxx Together with the first part, in addition to testsuite/gcc.dg/plugin/one_time_plugin.c , this patch set allows testsuite/gcc.dg/plugin/ggcplug.c and testsuite/gcc.dg/plugin/dumb_plugin.c to be compiled with gcc into a functioning gcc plugin. 2010-06-08 Joern Rennecke PR plugins/44459: * tree.h: Encapsulate declarations for tree accessor failure functions in extern "C". * diagnostic-core.h (warning): Encapsulate declaration in extern "C". * system.h (fancy_abort): Encapsulate declaration in extern "C". Index: tree.h =================================================================== --- tree.h (revision 160389) +++ tree.h (working copy) @@ -871,6 +871,10 @@ enum tree_node_structure_enum { (*({__typeof (NODE) const __t = (NODE); \ &__t->common.type; })) +/* Make accessor macros usable in plugins compiled as C. */ +#ifdef __cplusplus +extern "C" { +#endif extern void tree_contains_struct_check_failed (const_tree, const enum tree_node_structure_enum, const char *, int, const char *) @@ -910,6 +914,9 @@ extern void omp_clause_range_check_faile const char *, enum omp_clause_code, enum omp_clause_code) ATTRIBUTE_NORETURN; +#ifdef __cplusplus +} +#endif #else /* not ENABLE_TREE_CHECKING, or not gcc */ Index: diagnostic-core.h =================================================================== --- diagnostic-core.h (revision 160389) +++ diagnostic-core.h (working copy) @@ -55,7 +55,14 @@ extern const char *trim_filename (const extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2) ATTRIBUTE_NORETURN; /* Pass one of the OPT_W* from options.h as the first parameter. */ +#ifdef __cplusplus +extern "C" { +#endif +/* C linkage so that plugins can use it more easyly. */ extern bool warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); +#ifdef __cplusplus +} +#endif extern bool warning_at (location_t, int, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); Index: system.h =================================================================== --- system.h (revision 160389) +++ system.h (working copy) @@ -586,7 +586,14 @@ extern int vsnprintf(char *, size_t, con /* Redefine abort to report an internal error w/o coredump, and reporting the location of the error in the source file. */ +#ifdef __cplusplus +extern "C" { +#endif +/* C linkage so that it can be used more easily by plugins. */ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; +#ifdef __cplusplus +} +#endif #define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__) /* Use gcc_assert(EXPR) to test invariants. */