From 178dd270cfc0599bd0df5dab286c4915903325aa Mon Sep 17 00:00:00 2001 From: tiancaishaonvjituizi <452565578@qq.com> Date: Tue, 26 Apr 2022 15:00:38 +0800 Subject: [PATCH] use more aggressive way --- paddle/utils/variant.h | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/paddle/utils/variant.h b/paddle/utils/variant.h index ed579edf18772..7b11ae1bee88c 100644 --- a/paddle/utils/variant.h +++ b/paddle/utils/variant.h @@ -13,6 +13,11 @@ #pragma once +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 9 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-copy" +#endif + /* variant synopsis @@ -1823,20 +1828,6 @@ struct dtor { template class destructor; -// gcc >= 9 has a bug that creates a false positive warning -// Reference: -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92145 -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89381 -#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 9 -#define USING_SUPER_ASSIGNMENT_OPERATOR \ -_Pragma("GCC diagnostic push") \ -_Pragma("GCC diagnostic ignored \"-Wdeprecated-copy\"") \ -using super::operator=; \ -_Pragma("GCC diagnostic pop") -#else -#define USING_SUPER_ASSIGNMENT_OPERATOR using super::operator=; -#endif - #define MPARK_VARIANT_DESTRUCTOR(destructible_trait, definition, destroy) \ template \ class destructor, destructible_trait> \ @@ -1845,7 +1836,7 @@ _Pragma("GCC diagnostic pop") \ public: \ MPARK_INHERITING_CTOR(destructor, super) \ - USING_SUPER_ASSIGNMENT_OPERATOR \ + using super::operator=; \ \ destructor(const destructor &) = default; \ destructor(destructor &&) = default; \ @@ -1881,7 +1872,7 @@ class constructor : public destructor { public: MPARK_INHERITING_CTOR(constructor, super) - USING_SUPER_ASSIGNMENT_OPERATOR + using super::operator=; protected: #ifndef MPARK_GENERIC_LAMBDAS @@ -1933,7 +1924,7 @@ class move_constructor; \ public: \ MPARK_INHERITING_CTOR(move_constructor, super) \ - USING_SUPER_ASSIGNMENT_OPERATOR \ + using super::operator=; \ \ move_constructor(const move_constructor &) = default; \ definition ~move_constructor() = default; \ @@ -1969,7 +1960,7 @@ class copy_constructor; \ public: \ MPARK_INHERITING_CTOR(copy_constructor, super) \ - USING_SUPER_ASSIGNMENT_OPERATOR \ + using super::operator=; \ \ definition copy_constructor(copy_constructor &&) = default; \ ~copy_constructor() = default; \ @@ -1998,7 +1989,7 @@ class assignment : public copy_constructor { public: MPARK_INHERITING_CTOR(assignment, super) - USING_SUPER_ASSIGNMENT_OPERATOR + using super::operator=; template inline /* auto & */ auto emplace(Args &&... args) @@ -2085,7 +2076,7 @@ class move_assignment; \ public: \ MPARK_INHERITING_CTOR(move_assignment, super) \ - USING_SUPER_ASSIGNMENT_OPERATOR \ + using super::operator=; \ \ move_assignment(const move_assignment &) = default; \ move_assignment(move_assignment &&) = default; \ @@ -2125,7 +2116,7 @@ class copy_assignment; \ public: \ MPARK_INHERITING_CTOR(copy_assignment, super) \ - USING_SUPER_ASSIGNMENT_OPERATOR \ + using super::operator=; \ \ copy_assignment(const copy_assignment &) = default; \ copy_assignment(copy_assignment &&) = default; \ @@ -2155,7 +2146,7 @@ class impl : public copy_assignment> { public: MPARK_INHERITING_CTOR(impl, super) - USING_SUPER_ASSIGNMENT_OPERATOR + using super::operator=; template inline void assign(Arg &&arg) { @@ -2842,3 +2833,7 @@ struct hash { }; } // namespace std + +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 9 +#pragma GCC diagnostic pop +#endif