Skip to content

Commit

Permalink
Disable tests for unique addressing for msvc and partially for gcc 4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
pfultz2 committed Jun 23, 2016
1 parent 6e767a0 commit bc8b5bc
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 72 deletions.
15 changes: 1 addition & 14 deletions include/fit/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,6 @@
#endif
#endif

// Whether static variables will be a unique address across translation units.
// This can affect PCH on MSVC, so its currently disabled.
#ifndef FIT_NO_UNIQUE_STATIC_VAR
#define FIT_NO_UNIQUE_STATIC_VAR 0
#endif

// Whether static variables from lambdas will be a unique address across
// translation units. This is only supported on compilers that can do a
// constexpr reintrepret_cast.
#ifndef FIT_NO_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR
#define FIT_NO_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR 0
#endif

// Whether to use template aliases
#ifndef FIT_HAS_TEMPLATE_ALIAS
#if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 8
Expand Down Expand Up @@ -148,7 +135,7 @@
#endif
#endif

// SOme type expansion failures on gcc 4.6
// Some type expansion failures on gcc 4.6
#ifndef FIT_NO_TYPE_PACK_EXPANSION_IN_TEMPLATE
#if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
#define FIT_NO_TYPE_PACK_EXPANSION_IN_TEMPLATE 1
Expand Down
33 changes: 0 additions & 33 deletions include/fit/detail/inline_var.hpp

This file was deleted.

10 changes: 8 additions & 2 deletions include/fit/detail/static_const_var.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FIT_GUARD_STATIC_CONST_H
#define FIT_GUARD_STATIC_CONST_H

#include <fit/detail/inline_var.hpp>
#include <fit/detail/intrinsics.hpp>

namespace fit { namespace detail {

Expand All @@ -29,7 +29,7 @@ struct static_const_var_factory
template<class T>
constexpr const T& operator=(const T&) const
{
// static_assert(FIT_IS_DEFAULT_CONSTRUCTIBLE(T), "Static const variable must be default constructible");
static_assert(FIT_IS_DEFAULT_CONSTRUCTIBLE(T), "Static const variable must be default constructible");
return static_const_storage<T>::value;
}
};
Expand All @@ -44,6 +44,12 @@ constexpr const T& static_const_var()

} // namespace fit

#if FIT_HAS_RELAXED_CONSTEXPR || defined(_MSC_VER)
#define FIT_STATIC_CONSTEXPR const constexpr
#else
#define FIT_STATIC_CONSTEXPR static constexpr
#endif

#if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
#define FIT_STATIC_AUTO_REF extern __attribute__((weak)) constexpr auto
#else
Expand Down
19 changes: 0 additions & 19 deletions include/fit/detail/static_constexpr.hpp

This file was deleted.

4 changes: 2 additions & 2 deletions test/static_def/static_def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ int main()
if (fit_test::fit_sum_lambda(1, 2) != 3) printf("FAILED\n");
if (fit_test::fit_sum(1, 2) != 3) printf("FAILED\n");

#if !FIT_NO_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR
#if FIT_HAS_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR
if (sum_lambda_addr() != f_sum_lambda_addr()) printf("FAILED: Lambda\n");
if (sum_fo_addr() != f_sum_fo_addr()) printf("FAILED: Function object\n");
#endif

#if !FIT_NO_UNIQUE_STATIC_VAR
#if FIT_HAS_UNIQUE_STATIC_VAR
if (sum_var_addr() != f_sum_var_addr()) printf("FAILED: Lambda\n");
if (sum_constexpr_fo_addr() != f_sum_constexpr_fo_addr()) printf("FAILED: Function object\n");
#endif
Expand Down
13 changes: 13 additions & 0 deletions test/static_def/static_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
#include <fit/function.hpp>
#include <fit/lambda.hpp>

// MSVC seems to not support unique addressing at all
#if defined (_MSC_VER)
#define FIT_HAS_UNIQUE_STATIC_VAR 0
#define FIT_HAS_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR 0
// Gcc 4.6 only supports unique addressing for non-lambdas
#elif defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
#define FIT_HAS_UNIQUE_STATIC_VAR 1
#define FIT_HAS_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR 0
#else
#define FIT_HAS_UNIQUE_STATIC_VAR 1
#define FIT_HAS_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR 1
#endif

namespace fit_test {

FIT_STATIC_LAMBDA_FUNCTION(fit_sum_lambda) = [](int x, int y)
Expand Down
4 changes: 2 additions & 2 deletions test/static_def/static_def2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ int f()
if (fit_test::fit_sum_lambda(1, 2) != 3) printf("FAILED\n");
if (fit_test::fit_sum(1, 2) != 3) printf("FAILED\n");

#if !FIT_NO_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR
#if FIT_HAS_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR
if (sum_lambda_addr() != f_sum_lambda_addr()) printf("FAILED: Lambda\n");
if (sum_fo_addr() != f_sum_fo_addr()) printf("FAILED: Function object\n");
#endif

#if !FIT_NO_UNIQUE_STATIC_VAR
#if FIT_HAS_UNIQUE_STATIC_VAR
if (sum_var_addr() != f_sum_var_addr()) printf("FAILED: Lambda\n");
if (sum_constexpr_fo_addr() != f_sum_constexpr_fo_addr()) printf("FAILED: Function object\n");
#endif
Expand Down

0 comments on commit bc8b5bc

Please sign in to comment.