From patchwork Tue Oct 11 13:09:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 16420 Received: (qmail 41103 invoked by alias); 11 Oct 2016 13:09:31 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 41047 invoked by uid 89); 11 Oct 2016 13:09:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=H*MI:panix, H*r:10.0.0, __gnuc_prereq, __GNUC_PREREQ X-HELO: mail-qk0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=wb02D++NVmrkTVcuDe6XLF+KC3yh80uEnZ6TNXzcuyE=; b=N7sBnjj9WZ5fTKOQiuTNGIvf4hd0tQdJ6qLugE2O0kcNvslaQIkchelnO0mdATJJq7 +IQG4FXc0LuKj+sDyqzPbLypkTYu7bYxTuL2vkgzWOrA/B2pjW6fXDUapYEqvwyhpLVO bajkG9iQfHtT6V2SVLRqVgNAmxwpAfdviPD20C9hpjxJB1SuEGats7S8cc9OmewkU7Nt sEOET8D7jJp3m4Nw9Xapai05iBpzYrN6Lq0duMK1kzeuzDyJIujgwB6GOsJalW+rf8LI Y9D3Ru2OrFoIuJyTiu4vou4Sd+dI5WrVN5YbNHaVjGRwuwz3NlJo3NRsMMi9mZXSvadK DCAA== X-Gm-Message-State: AA6/9Rm20UGBkq1XYc8lJnJBDRTJYP6ico6SpPbmj98tnfuPzDvcc5fvfErWbHepJWyVhg== X-Received: by 10.55.42.144 with SMTP id q16mr3682010qkq.257.1476191367501; Tue, 11 Oct 2016 06:09:27 -0700 (PDT) To: GNU C Library From: Zack Weinberg Subject: [PATCH BZ#19239] Improve deprecation warnings Message-ID: <87b07b5c-04f3-9ce6-1550-5895fb4b3865@panix.com> Date: Tue, 11 Oct 2016 09:09:25 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 By using __glibc_macro_warning instead of __attribute_deprecated__, we get the deprecation warnings whenever the macros are expanded, not just when they compile to a function call. This is important for unintentional uses like the test case in #19239. It's also simpler, because __REDIRECT is no longer required. __SYSMACROS_DM(1) is tricksy: by writing the full text of the deprecation message directly inside the call to __SYSMACROS_DM1, we prevent all those bare identifiers from being macro-expanded (because they're the immediate subject of stringification) while still being able to substitute ‘symbol’. (Neither _Pragma itself nor #pragma GCC warning permits string-literal concatenation.) OK? zw diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 50e00e6..49b0956 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -474,7 +474,7 @@ /* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is intended for use in preprocessor macros. */ -#if __GNUC_PREREQ (4,8) +#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5) # define __glibc_macro_warning1(message) _Pragma (#message) # define __glibc_macro_warning(message) \ __glibc_macro_warning1 (GCC warning message) diff --git a/misc/sys/sysmacros.h b/misc/sys/sysmacros.h index 086e9af..5600672 100644 --- a/misc/sys/sysmacros.h +++ b/misc/sys/sysmacros.h @@ -40,54 +40,39 @@ #include #include -/* The extra "\n " moves gcc's [-Wdeprecated-declarations] annotation - onto the next line. */ -#define __SYSMACROS_DEPRECATION_MSG(symbol) \ - "\n In the GNU C Library, `" #symbol "' is defined by ." \ - "\n For historical compatibility, it is currently defined by" \ - "\n as well, but we plan to remove this soon." \ - "\n To use `" #symbol "', include directly." \ - "\n If you did not intend to use a system-defined macro `" #symbol "'," \ - "\n you should #undef it after including ." \ - "\n " +/* Caution: if you change the whitespace in and around this macro, + it may malfunction. Newline placement is tuned for GCC 6. */ +#define __SYSMACROS_DM(symbol) __SYSMACROS_DM1 \ + (In the GNU C Library, #symbol is defined\n\ + by . For historical compatibility, it is\n\ + currently defined by as well, but we plan to\n\ + remove this soon. To use #symbol, include \n\ + directly. If you did not intend to use a system-defined macro\n\ + #symbol, you should undefine it after including .) + +/* This macro is variadic because the deprecation message above + contains commas. */ +#define __SYSMACROS_DM1(...) __glibc_macro_warning (#__VA_ARGS__) #define __SYSMACROS_DECL_TEMPL(rtype, name, proto) \ extern rtype gnu_dev_##name proto __THROW __attribute_const__; -#define __SYSMACROS_FST_DECL_TEMPL(rtype, name, proto) \ - extern rtype __REDIRECT_NTH (__##name##_from_sys_types, proto, \ - gnu_dev_##name) \ - __attribute_const__ \ - __attribute_deprecated_msg__ (__SYSMACROS_DEPRECATION_MSG (name)); - #define __SYSMACROS_IMPL_TEMPL(rtype, name, proto) \ __extension__ __extern_inline __attribute_const__ rtype \ __NTH (gnu_dev_##name proto) -#define __SYSMACROS_FST_IMPL_TEMPL(rtype, name, proto) \ - __extension__ __extern_inline __attribute_const__ rtype \ - __NTH (__##name##_from_sys_types proto) - __BEGIN_DECLS __SYSMACROS_DECLARE_MAJOR (__SYSMACROS_DECL_TEMPL) __SYSMACROS_DECLARE_MINOR (__SYSMACROS_DECL_TEMPL) __SYSMACROS_DECLARE_MAKEDEV (__SYSMACROS_DECL_TEMPL) -__SYSMACROS_DECLARE_MAJOR (__SYSMACROS_FST_DECL_TEMPL) -__SYSMACROS_DECLARE_MINOR (__SYSMACROS_FST_DECL_TEMPL) -__SYSMACROS_DECLARE_MAKEDEV (__SYSMACROS_FST_DECL_TEMPL) - #ifdef __USE_EXTERN_INLINES __SYSMACROS_DEFINE_MAJOR (__SYSMACROS_IMPL_TEMPL) __SYSMACROS_DEFINE_MINOR (__SYSMACROS_IMPL_TEMPL) __SYSMACROS_DEFINE_MAKEDEV (__SYSMACROS_IMPL_TEMPL) -__SYSMACROS_DEFINE_MAJOR (__SYSMACROS_FST_IMPL_TEMPL) -__SYSMACROS_DEFINE_MINOR (__SYSMACROS_FST_IMPL_TEMPL) -__SYSMACROS_DEFINE_MAKEDEV (__SYSMACROS_FST_IMPL_TEMPL) - #endif