Commit 11aeda2a authored by Joe Loser's avatar Joe Loser Committed by Facebook Github Bot

Remove macro guards against GCC 4.9 code (#1096)

Summary:
- Since folly requires GCC 5+ compiler, remove several macros which were
  guarding against when we supported GCC 4.9.
Pull Request resolved: https://github.com/facebook/folly/pull/1096

Reviewed By: LeeHowes

Differential Revision: D14681043

Pulled By: LeeHowes

fbshipit-source-id: fcc2cd25e00c512f7154a1568003e7c2f0df9c54
parent 54a23fa3
...@@ -100,13 +100,6 @@ constexpr const Char (&checkNullTerminated(const Char (&a)[N]) noexcept)[N] { ...@@ -100,13 +100,6 @@ constexpr const Char (&checkNullTerminated(const Char (&a)[N]) noexcept)[N] {
: (assertNotNullTerminated(), decltype(a)(a)); : (assertNotNullTerminated(), decltype(a)(a));
} }
// Rather annoyingly, GCC's -Warray-bounds warning issues false positives for
// this code. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61971
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 5
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
template <class Left, class Right> template <class Left, class Right>
constexpr ordering compare_( constexpr ordering compare_(
const Left& left, const Left& left,
...@@ -302,10 +295,6 @@ struct Helper { ...@@ -302,10 +295,6 @@ struct Helper {
} }
}; };
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 4
#pragma GCC diagnostic pop
#endif
template <class T> template <class T>
constexpr void constexpr_swap(T& a, T& b) noexcept( constexpr void constexpr_swap(T& a, T& b) noexcept(
noexcept(a = T(std::move(a)))) { noexcept(a = T(std::move(a)))) {
......
/*
* Copyright 2017-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
#pragma message "Folly.Poly requires gcc-5 or greater"
#else
#include <folly/Poly.h>
namespace folly {
namespace detail {
// empty
} // namespace detail
} // namespace folly
#endif
...@@ -25,10 +25,6 @@ ...@@ -25,10 +25,6 @@
#pragma once #pragma once
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
#error Folly.Poly requires gcc-5 or greater
#endif
#include <cassert> #include <cassert>
#include <new> #include <new>
#include <type_traits> #include <type_traits>
......
...@@ -202,11 +202,6 @@ constexpr bool kIsSanitize = false; ...@@ -202,11 +202,6 @@ constexpr bool kIsSanitize = false;
#define FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS /* empty */ #define FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS /* empty */
#endif #endif
// Globally disable -Wshadow for gcc < 5.
#if __GNUC__ == 4 && !__clang__
FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS
#endif
/* Platform specific TLS support /* Platform specific TLS support
* gcc implements __thread * gcc implements __thread
* msvc implements __declspec(thread) * msvc implements __declspec(thread)
......
...@@ -308,9 +308,6 @@ using aligned_storage_for_t = ...@@ -308,9 +308,6 @@ using aligned_storage_for_t =
#if defined(__clang__) && !defined(_LIBCPP_VERSION) #if defined(__clang__) && !defined(_LIBCPP_VERSION)
template <class T> template <class T>
struct is_trivially_copyable : bool_constant<__is_trivially_copyable(T)> {}; struct is_trivially_copyable : bool_constant<__is_trivially_copyable(T)> {};
#elif defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
template <class T>
struct is_trivially_copyable : std::is_trivial<T> {};
#else #else
template <class T> template <class T>
using is_trivially_copyable = std::is_trivially_copyable<T>; using is_trivially_copyable = std::is_trivially_copyable<T>;
......
...@@ -27,8 +27,6 @@ TEST(ConstexprTest, constexpr_strlen_cstr) { ...@@ -27,8 +27,6 @@ TEST(ConstexprTest, constexpr_strlen_cstr) {
EXPECT_TRUE((std::is_same<const size_t, decltype(a)>::value)); EXPECT_TRUE((std::is_same<const size_t, decltype(a)>::value));
} }
// gcc-4.9 cannot compile the following constexpr code correctly
#if !(defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5)
TEST(ConstexprTest, constexpr_strlen_ints) { TEST(ConstexprTest, constexpr_strlen_ints) {
constexpr int v[] = {5, 3, 4, 0, 7}; constexpr int v[] = {5, 3, 4, 0, 7};
constexpr auto a = folly::constexpr_strlen(v); constexpr auto a = folly::constexpr_strlen(v);
...@@ -42,7 +40,6 @@ TEST(ConstexprTest, constexpr_strcmp_ints) { ...@@ -42,7 +40,6 @@ TEST(ConstexprTest, constexpr_strcmp_ints) {
static_assert(constexpr_strcmp(v1, v) > 0, "constexpr_strcmp is broken"); static_assert(constexpr_strcmp(v1, v) > 0, "constexpr_strcmp is broken");
static_assert(constexpr_strcmp(v, v) == 0, "constexpr_strcmp is broken"); static_assert(constexpr_strcmp(v, v) == 0, "constexpr_strcmp is broken");
} }
#endif
static_assert( static_assert(
constexpr_strcmp("abc", "abc") == 0, constexpr_strcmp("abc", "abc") == 0,
......
...@@ -668,7 +668,7 @@ struct WithConstructor { ...@@ -668,7 +668,7 @@ struct WithConstructor {
// libstdc++ with GCC 4.x doesn't have std::is_trivially_copyable // libstdc++ with GCC 4.x doesn't have std::is_trivially_copyable
#if (defined(__clang__) && !defined(_LIBCPP_VERSION)) || \ #if (defined(__clang__) && !defined(_LIBCPP_VERSION)) || \
!(defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5) !(defined(__GNUC__) && !defined(__clang__))
TEST(Expected, TriviallyCopyable) { TEST(Expected, TriviallyCopyable) {
// These could all be static_asserts but EXPECT_* give much nicer output on // These could all be static_asserts but EXPECT_* give much nicer output on
// failure. // failure.
......
...@@ -648,30 +648,6 @@ TEST(FixedStringReverseIteratorTest, ConstexprReverseIteration) { ...@@ -648,30 +648,6 @@ TEST(FixedStringReverseIteratorTest, ConstexprReverseIteration) {
static_assert((alpha.rend() - 2) == (alpha.rbegin() + 24), ""); static_assert((alpha.rend() - 2) == (alpha.rbegin() + 24), "");
} }
namespace GCC61971 {
// FixedString runs afoul of GCC #61971 (spurious -Warray-bounds)
// in optimized builds. The following test case triggers it for gcc-4.x.
// Test that FixedString suppresses the warning correctly.
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61971
constexpr auto xyz = folly::makeFixedString("xyz");
constexpr auto dot = folly::makeFixedString(".");
template <typename T1>
constexpr auto concatStuff(const T1& component) noexcept {
return xyz + dot + component;
}
constexpr auto co = folly::makeFixedString("co");
struct S {
std::string s{concatStuff(co)};
};
} // namespace GCC61971
TEST(FixedStringGCC61971, GCC61971) {
GCC61971::S s;
(void)s;
}
#include <folly/Range.h> #include <folly/Range.h>
TEST(FixedStringConversionTest, ConversionToFollyRange) { TEST(FixedStringConversionTest, ConversionToFollyRange) {
......
...@@ -13,9 +13,7 @@ ...@@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
#pragma message "Folly.Poly requires gcc-5 or greater"
#else
#include <folly/Poly.h> #include <folly/Poly.h>
#include <folly/Conv.h> #include <folly/Conv.h>
...@@ -835,4 +833,3 @@ TEST(Poly, PolyRefAsArg) { ...@@ -835,4 +833,3 @@ TEST(Poly, PolyRefAsArg) {
// should not throw: // should not throw:
frob.frobnicate(folly::Poly<folly::poly::IRegular&>(x)); frob.frobnicate(folly::Poly<folly::poly::IRegular&>(x));
} }
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment