From 9a0dd1f84a68225653ac28c779e01b79c21f578d Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Mon, 25 Jan 2021 23:36:15 +0000 Subject: [PATCH] GCC doesn't deal with multiple pragmas in the same line correctly --- src/include/build.h | 20 ++------------------ src/lib/curl/base.h | 4 +++- src/lib/curl/io.c | 4 +++- src/lib/json/base.h | 6 ++++-- src/lib/json/json_missing.h | 6 ++++-- src/lib/util/event.c | 4 +++- src/modules/rlm_mruby/rlm_mruby.c | 6 ++++-- src/modules/rlm_mruby/rlm_mruby.h | 6 ++++-- src/modules/rlm_perl/rlm_perl.c | 6 ++++-- src/modules/rlm_unbound/io.h | 6 ++++-- src/modules/rlm_unbound/log.h | 6 ++++-- 11 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/include/build.h b/src/include/build.h index b45f749f47..3e7c7c86af 100644 --- a/src/include/build.h +++ b/src/include/build.h @@ -168,38 +168,22 @@ extern "C" { * Macros for controlling warnings in GCC >= 4.2 and clang >= 2.8 */ #if defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__ >= 208) +# define DIAG_UNKNOWN_PRAGMAS unknown-pragmas # define DIAG_PRAGMA(_x) PRAGMA(clang diagnostic _x) # define DIAG_OFF(_x) DIAG_PRAGMA(ignored JOINSTR(-W,_x)) # define DIAG_ON(_x) DIAG_PRAGMA(warning JOINSTR(-W,_x)) -# define DIAG_OFF_OPTIONAL(_x) \ - DIAG_OFF(ignored unknown-pragmas) \ - DIAG_OFF(_x) \ - DIAG_ON(warning unknown-pragmas) -# define DIAG_ON_OPTIONAL(_x) \ - DIAG_OFF(unknown-pragmas) \ - DIAG_ON(_x) \ - DIAG_ON(unknown-pragmas) # define DIAG_PUSH() DIAG_PRAGMA(push) # define DIAG_POP() DIAG_PRAGMA(pop) #elif !defined(__clang__) && defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 +# define DIAG_UNKNOWN_PRAGMAS pragmas # define DIAG_PRAGMA(_x) PRAGMA(GCC diagnostic _x) # define DIAG_OFF(_x) DIAG_PRAGMA(ignored JOINSTR(-W,_x)) # define DIAG_ON(_x) DIAG_PRAGMA(warning JOINSTR(-W,_x)) -# define DIAG_OFF_OPTIONAL(_x) \ - DIAG_OFF(pragmas) \ - DIAG_OFF(_x) \ - DIAG_ON(pragmas) -# define DIAG_ON_OPTIONAL(_x) \ - DIAG_OFF(pragmas) \ - DIAG_ON(_x) \ - DIAG_ON(pragmas) # define DIAG_PUSH() DIAG_PRAGMA(push) # define DIAG_POP() DIAG_PRAGMA(pop) #else # define DIAG_OFF(_x) # define DIAG_ON(_x) -# define DIAG_OFF_OPTIONAL(_x) -# define DIAG_ON_OPTIONAL(_x) # define DIAG_PUSH() # define DIAG_POP() #endif diff --git a/src/lib/curl/base.h b/src/lib/curl/base.h index 1b71c6fa8d..3d406eaf05 100644 --- a/src/lib/curl/base.h +++ b/src/lib/curl/base.h @@ -36,7 +36,9 @@ extern "C" { #include #include -DIAG_OFF_OPTIONAL(disabled-macro-expansion) +DIAG_OFF(DIAG_UNKNOWN_PRAGMAS) +DIAG_OFF(disabled-macro-expansion) +DIAG_ON(DIAG_UNKNOWN_PRAGMAS) #define FR_CURL_SET_OPTION(_x, _y)\ do {\ int _ret;\ diff --git a/src/lib/curl/io.c b/src/lib/curl/io.c index 14ab4da80f..d91e357427 100644 --- a/src/lib/curl/io.c +++ b/src/lib/curl/io.c @@ -32,7 +32,9 @@ * * #define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param) */ -DIAG_OFF_OPTIONAL(disabled-macro-expansion) +DIAG_OFF(DIAG_UNKNOWN_PRAGMAS) +DIAG_OFF(disabled-macro-expansion) +DIAG_ON(DIAG_UNKNOWN_PRAGMAS) #define SET_MOPTION(_mandle, _opt, _val)\ do {\ if ((ret = curl_multi_setopt(mandle, _opt, _val)) != CURLM_OK) {\ diff --git a/src/lib/json/base.h b/src/lib/json/base.h index 75a5906820..729fae87fe 100644 --- a/src/lib/json/base.h +++ b/src/lib/json/base.h @@ -34,9 +34,11 @@ RCSIDH(json_h, "$Id$") #ifdef HAVE_JSON # if defined(HAVE_JSONMC_JSON_H) -DIAG_OFF_OPTIONAL(documentation-deprecated-sync) +DIAG_OFF(DIAG_UNKNOWN_PRAGMAS) +DIAG_OFF(documentation-deprecated-sync) # include -DIAG_ON_OPTIONAL(documentation-deprecated-sync) +DIAG_ON(documentation-deprecated-sync) +DIAG_ON(DIAG_UNKNOWN_PRAGMAS) # elif defined(HAVE_JSON_JSON_H) # include diff --git a/src/lib/json/json_missing.h b/src/lib/json/json_missing.h index ae614b0bbd..bf72ffd53e 100644 --- a/src/lib/json/json_missing.h +++ b/src/lib/json/json_missing.h @@ -29,9 +29,11 @@ RCSIDH(jsonc_missing_h, "$Id$") #ifdef HAVE_JSON # if defined(HAVE_JSONMC_JSON_H) -DIAG_OFF_OPTIONAL(documentation-deprecated-sync) +DIAG_OFF(DIAG_UNKNOWN_PRAGMAS) +DIAG_OFF(documentation-deprecated-sync) # include -DIAG_ON_OPTIONAL(documentation-deprecated-sync) +DIAG_ON(documentation-deprecated-sync) +DIAG_ON(DIAG_UNKNOWN_PRAGMAS) # elif defined(HAVE_JSON_JSON_H) # include diff --git a/src/lib/util/event.c b/src/lib/util/event.c index 1a6535226a..deb41bd7f7 100644 --- a/src/lib/util/event.c +++ b/src/lib/util/event.c @@ -50,7 +50,9 @@ RCSID("$Id$") * Turn off documentation warnings as file/line * args aren't used for non-debug builds. */ -DIAG_OFF_OPTIONAL(documentation) +DIAG_OFF(DIAG_UNKNOWN_PRAGMAS) +DIAG_OFF(documentation) +DIAG_ON(DIAG_UNKNOWN_PRAGMAS) #endif #define FR_EV_BATCH_FDS (256) diff --git a/src/modules/rlm_mruby/rlm_mruby.c b/src/modules/rlm_mruby/rlm_mruby.c index 991b3c68ae..c2a230532a 100644 --- a/src/modules/rlm_mruby/rlm_mruby.c +++ b/src/modules/rlm_mruby/rlm_mruby.c @@ -413,9 +413,11 @@ static unlang_action_t CC_HINT(nonnull) do_mruby(rlm_rcode_t *p_result, request_ mruby_set_vps(request, mrb, mruby_request, "@control", &request->control_pairs); mruby_set_vps(request, mrb, mruby_request, "@session_state", &request->session_state_pairs); -DIAG_OFF_OPTIONAL(class-varargs) +DIAG_OFF(DIAG_UNKNOWN_PRAGMAS) +DIAG_OFF(class-varargs) mruby_result = mrb_funcall(mrb, mrb_obj_value(inst->mruby_module), function_name, 1, mruby_request); -DIAG_ON_OPTIONAL(class-varargs) +DIAG_ON(class-varargs) +DIAG_ON(DIAG_UNKNOWN_PRAGMAS) /* Two options for the return value: * - a fixnum: convert to rlm_rcode_t, and return that diff --git a/src/modules/rlm_mruby/rlm_mruby.h b/src/modules/rlm_mruby/rlm_mruby.h index 0c067dcf17..ec168fbfcf 100644 --- a/src/modules/rlm_mruby/rlm_mruby.h +++ b/src/modules/rlm_mruby/rlm_mruby.h @@ -23,7 +23,8 @@ * @copyright 2016 The FreeRADIUS server project */ -DIAG_OFF_OPTIONAL(documentation) +DIAG_OFF(DIAG_UNKNOWN_PRAGMAS) +DIAG_OFF(documentation) #include #include #include @@ -31,6 +32,7 @@ DIAG_OFF_OPTIONAL(documentation) #include #include #include -DIAG_ON_OPTIONAL(documentation) +DIAG_ON(documentation) +DIAG_ON(DIAG_UNKNOWN_PRAGMAS) struct RClass *mruby_request_class(mrb_state *mrb, struct RClass *parent); diff --git a/src/modules/rlm_perl/rlm_perl.c b/src/modules/rlm_perl/rlm_perl.c index 8cabde4fbf..10783e4b19 100644 --- a/src/modules/rlm_perl/rlm_perl.c +++ b/src/modules/rlm_perl/rlm_perl.c @@ -197,7 +197,8 @@ static void rlm_perl_close_handles(void **handles) talloc_free(handles); } -DIAG_OFF_OPTIONAL(shadow) +DIAG_OFF(DIAG_UNKNOWN_PRAGMAS) +DIAG_OFF(shadow) static void rlm_perl_destruct(PerlInterpreter *perl) { dTHXa(perl); @@ -223,7 +224,8 @@ static void rlm_perl_destruct(PerlInterpreter *perl) perl_destruct(perl); perl_free(perl); } -DIAG_ON_OPTIONAL(shadow) +DIAG_ON(shadow) +DIAG_ON(DIAG_UNKNOWN_PRAGMAS) static void rlm_destroy_perl(PerlInterpreter *perl) { diff --git a/src/modules/rlm_unbound/io.h b/src/modules/rlm_unbound/io.h index bbfb49ac3b..3756341a79 100644 --- a/src/modules/rlm_unbound/io.h +++ b/src/modules/rlm_unbound/io.h @@ -30,10 +30,12 @@ RCSIDH(rlm_unbound_io_h, "$Id$") extern "C" { #endif -DIAG_OFF_OPTIONAL(documentation) +DIAG_OFF(DIAG_UNKNOWN_PRAGMAS) +DIAG_OFF(documentation) #include #include -DIAG_ON_OPTIONAL(documentation) +DIAG_ON(documentation) +DIAG_ON(DIAG_UNKNOWN_PRAGMAS) /** Wrapper around our event loop specifying callbacks for creating new event handles * diff --git a/src/modules/rlm_unbound/log.h b/src/modules/rlm_unbound/log.h index 0643d1fcea..2aed20f830 100644 --- a/src/modules/rlm_unbound/log.h +++ b/src/modules/rlm_unbound/log.h @@ -32,9 +32,11 @@ extern "C" { #include -DIAG_OFF_OPTIONAL(documentation) +DIAG_OFF(DIAG_UNKNOWN_PRAGMAS) +DIAG_OFF(documentation) #include -DIAG_ON_OPTIONAL(documentation) +DIAG_ON(documentation) +DIAG_ON(DIAG_UNKNOWN_PRAGMAS) /** Logging state * -- 2.47.2