Skip to content

Commit

Permalink
Remove code pieces for no longer supported MSVC versions.
Browse files Browse the repository at this point in the history
The current support policy is `_MSC_VER >= 1920`.

PiperOrigin-RevId: 599833619
Change-Id: I9cf7393a5b659d1680765e37e0328539ccb870fa
  • Loading branch information
Abseil Team authored and copybara-github committed Jan 19, 2024
1 parent b03cda5 commit 04d8afe
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 39 deletions.
6 changes: 0 additions & 6 deletions absl/numeric/int128_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
#include "absl/hash/hash_testing.h"
#include "absl/meta/type_traits.h"

#if defined(_MSC_VER) && _MSC_VER == 1900
// Disable "unary minus operator applied to unsigned type" warnings in Microsoft
// Visual C++ 14 (2015).
#pragma warning(disable:4146)
#endif

#define MAKE_INT128(HI, LO) absl::MakeInt128(static_cast<int64_t>(HI), LO)

namespace {
Expand Down
2 changes: 1 addition & 1 deletion absl/strings/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ class string_view {
}

static constexpr size_type StrlenInternal(absl::Nonnull<const char*> str) {
#if defined(_MSC_VER) && _MSC_VER >= 1910 && !defined(__clang__)
#if defined(_MSC_VER) && !defined(__clang__)
// MSVC 2017+ can evaluate this at compile-time.
const char* begin = str;
while (*str != '\0') ++str;
Expand Down
4 changes: 0 additions & 4 deletions absl/strings/string_view_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1051,9 +1051,6 @@ TEST(StringViewTest, ConstexprNullSafeStringView) {
EXPECT_EQ(0u, s.size());
EXPECT_EQ(absl::string_view(), s);
}
#if !defined(_MSC_VER) || _MSC_VER >= 1910
// MSVC 2017+ is required for good constexpr string_view support.
// See the implementation of `absl::string_view::StrlenInternal()`.
{
static constexpr char kHi[] = "hi";
absl::string_view s = absl::NullSafeStringView(kHi);
Expand All @@ -1066,7 +1063,6 @@ TEST(StringViewTest, ConstexprNullSafeStringView) {
EXPECT_EQ(s.size(), 5u);
EXPECT_EQ("hello", s);
}
#endif
}

TEST(StringViewTest, ConstexprCompiles) {
Expand Down
5 changes: 2 additions & 3 deletions absl/synchronization/lifetime_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ class OnDestruction {
};

// These tests require that the compiler correctly supports C++11 constant
// initialization... but MSVC has a known regression since v19.10 till v19.25:
// initialization... but MSVC has a known regression (since v19.10) till v19.25:
// https://developercommunity.visualstudio.com/content/problem/336946/class-with-constexpr-constructor-not-using-static.html
#if defined(__clang__) || \
!(defined(_MSC_VER) && _MSC_VER > 1900 && _MSC_VER < 1925)
#if defined(__clang__) || !(defined(_MSC_VER) && _MSC_VER < 1925)
// kConstInit
// Test early usage. (Declaration comes first; definitions must appear after
// the test runner.)
Expand Down
27 changes: 2 additions & 25 deletions absl/types/optional_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -994,25 +994,6 @@ TEST(optionalTest, PointerStuff) {
#endif
#endif

// MSVC has a bug with "cv-qualifiers in class construction", fixed in 2017. See
// https://docs.microsoft.com/en-us/cpp/cpp-conformance-improvements-2017#bug-fixes
// The compiler some incorrectly ignores the cv-qualifier when generating a
// class object via a constructor call. For example:
//
// class optional {
// constexpr T&& value() &&;
// constexpr const T&& value() const &&;
// }
//
// using COI = const absl::optional<int>;
// static_assert(2 == COI(2).value(), ""); // const &&
//
// This should invoke the "const &&" overload but since it ignores the const
// qualifier it finds the "&&" overload the best candidate.
#if defined(_MSC_VER) && _MSC_VER < 1910
#define ABSL_SKIP_OVERLOAD_TEST_DUE_TO_MSVC_BUG
#endif

TEST(optionalTest, Value) {
using O = absl::optional<std::string>;
using CO = const absl::optional<std::string>;
Expand All @@ -1032,8 +1013,7 @@ TEST(optionalTest, Value) {
EXPECT_EQ("c&", TypeQuals(clvalue.value()));
EXPECT_EQ("c&", TypeQuals(lvalue_c.value()));
EXPECT_EQ("&&", TypeQuals(O(absl::in_place, "xvalue").value()));
#if !defined(ABSL_SKIP_OVERLOAD_TEST_DUE_TO_MSVC_BUG) && \
!defined(ABSL_SKIP_OVERLOAD_TEST_DUE_TO_GCC_BUG)
#ifndef ABSL_SKIP_OVERLOAD_TEST_DUE_TO_GCC_BUG
EXPECT_EQ("c&&", TypeQuals(CO(absl::in_place, "cxvalue").value()));
#endif
EXPECT_EQ("c&&", TypeQuals(OC(absl::in_place, "xvalue_c").value()));
Expand Down Expand Up @@ -1083,8 +1063,7 @@ TEST(optionalTest, DerefOperator) {
EXPECT_EQ("&", TypeQuals(*lvalue));
EXPECT_EQ("c&", TypeQuals(*clvalue));
EXPECT_EQ("&&", TypeQuals(*O(absl::in_place, "xvalue")));
#if !defined(ABSL_SKIP_OVERLOAD_TEST_DUE_TO_MSVC_BUG) && \
!defined(ABSL_SKIP_OVERLOAD_TEST_DUE_TO_GCC_BUG)
#ifndef ABSL_SKIP_OVERLOAD_TEST_DUE_TO_GCC_BUG
EXPECT_EQ("c&&", TypeQuals(*CO(absl::in_place, "cxvalue")));
#endif
EXPECT_EQ("c&&", TypeQuals(*OC(absl::in_place, "xvalue_c")));
Expand Down Expand Up @@ -1117,11 +1096,9 @@ TEST(optionalTest, ValueOr) {
constexpr absl::optional<double> copt_empty, copt_set = {1.2};
static_assert(42.0 == copt_empty.value_or(42), "");
static_assert(1.2 == copt_set.value_or(42), "");
#ifndef ABSL_SKIP_OVERLOAD_TEST_DUE_TO_MSVC_BUG
using COD = const absl::optional<double>;
static_assert(42.0 == COD().value_or(42), "");
static_assert(1.2 == COD(1.2).value_or(42), "");
#endif
}

// make_optional cannot be constexpr until C++17
Expand Down

0 comments on commit 04d8afe

Please sign in to comment.