constant: Make const.allow_constexpr default to true.
This commit is contained in:
@@ -4,4 +4,4 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const uint32_t Foo_FOO = 42;
|
||||
constexpr static const uint32_t Foo_FOO = 42;
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
struct Foo {
|
||||
|
||||
};
|
||||
static const int32_t Foo_GA = 10;
|
||||
static const float Foo_ZO = 3.14;
|
||||
constexpr static const int32_t Foo_GA = 10;
|
||||
constexpr static const float Foo_ZO = 3.14;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ DEF NOT_DEFINED = 0
|
||||
#include <new>
|
||||
|
||||
#if defined(NOT_DEFINED)
|
||||
static const int32_t DEFAULT_X = 8;
|
||||
constexpr static const int32_t DEFAULT_X = 8;
|
||||
#endif
|
||||
|
||||
#if defined(DEFINED)
|
||||
static const int32_t DEFAULT_X = 42;
|
||||
constexpr static const int32_t DEFAULT_X = 42;
|
||||
#endif
|
||||
|
||||
#if (defined(NOT_DEFINED) || defined(DEFINED))
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const uint32_t Foo_FOO = 42;
|
||||
constexpr static const uint32_t Foo_FOO = 42;
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
|
||||
using Transparent = uint8_t;
|
||||
|
||||
static const Transparent FOO = 0;
|
||||
constexpr static const Transparent FOO = 0;
|
||||
|
||||
@@ -4,44 +4,44 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const int32_t FOO = 10;
|
||||
constexpr static const int32_t FOO = 10;
|
||||
|
||||
static const uint32_t DELIMITER = ':';
|
||||
constexpr static const uint32_t DELIMITER = ':';
|
||||
|
||||
static const uint32_t LEFTCURLY = '{';
|
||||
constexpr static const uint32_t LEFTCURLY = '{';
|
||||
|
||||
static const uint32_t QUOTE = '\'';
|
||||
constexpr static const uint32_t QUOTE = '\'';
|
||||
|
||||
static const uint32_t TAB = '\t';
|
||||
constexpr static const uint32_t TAB = '\t';
|
||||
|
||||
static const uint32_t NEWLINE = '\n';
|
||||
constexpr static const uint32_t NEWLINE = '\n';
|
||||
|
||||
static const uint32_t HEART = U'\U00002764';
|
||||
constexpr static const uint32_t HEART = U'\U00002764';
|
||||
|
||||
static const uint32_t EQUID = U'\U00010083';
|
||||
constexpr static const uint32_t EQUID = U'\U00010083';
|
||||
|
||||
static const float ZOM = 3.14;
|
||||
constexpr static const float ZOM = 3.14;
|
||||
|
||||
/// A single-line doc comment.
|
||||
static const int8_t POS_ONE = 1;
|
||||
constexpr static const int8_t POS_ONE = 1;
|
||||
|
||||
/// A
|
||||
/// multi-line
|
||||
/// doc
|
||||
/// comment.
|
||||
static const int8_t NEG_ONE = -1;
|
||||
constexpr static const int8_t NEG_ONE = -1;
|
||||
|
||||
static const int64_t SHIFT = 3;
|
||||
constexpr static const int64_t SHIFT = 3;
|
||||
|
||||
static const int64_t XBOOL = 1;
|
||||
constexpr static const int64_t XBOOL = 1;
|
||||
|
||||
static const int64_t XFALSE = ((0 << SHIFT) | XBOOL);
|
||||
constexpr static const int64_t XFALSE = ((0 << SHIFT) | XBOOL);
|
||||
|
||||
static const int64_t XTRUE = (1 << (SHIFT | XBOOL));
|
||||
constexpr static const int64_t XTRUE = (1 << (SHIFT | XBOOL));
|
||||
|
||||
static const uint8_t CAST = (uint8_t)'A';
|
||||
constexpr static const uint8_t CAST = (uint8_t)'A';
|
||||
|
||||
static const uint32_t DOUBLE_CAST = (uint32_t)(float)1;
|
||||
constexpr static const uint32_t DOUBLE_CAST = (uint32_t)(float)1;
|
||||
|
||||
struct Foo {
|
||||
int32_t x[FOO];
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const uint64_t UNSIGNED_NEEDS_ULL_SUFFIX = 9223372036854775808ULL;
|
||||
constexpr static const uint64_t UNSIGNED_NEEDS_ULL_SUFFIX = 9223372036854775808ULL;
|
||||
|
||||
static const uint64_t UNSIGNED_DOESNT_NEED_ULL_SUFFIX = 8070450532247928832;
|
||||
constexpr static const uint64_t UNSIGNED_DOESNT_NEED_ULL_SUFFIX = 8070450532247928832;
|
||||
|
||||
static const int64_t SIGNED_NEEDS_ULL_SUFFIX = -9223372036854775808ULL;
|
||||
constexpr static const int64_t SIGNED_NEEDS_ULL_SUFFIX = -9223372036854775808ULL;
|
||||
|
||||
static const int64_t SIGNED_DOESNT_NEED_ULL_SUFFIX = -9223372036854775807;
|
||||
constexpr static const int64_t SIGNED_DOESNT_NEED_ULL_SUFFIX = -9223372036854775807;
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
constexpr static const int64_t CONSTANT_I64 = 216;
|
||||
static const int64_t CONSTANT_I64 = 216;
|
||||
|
||||
constexpr static const float CONSTANT_FLOAT32 = 312.292;
|
||||
static const float CONSTANT_FLOAT32 = 312.292;
|
||||
|
||||
constexpr static const uint32_t DELIMITER = ':';
|
||||
static const uint32_t DELIMITER = ':';
|
||||
|
||||
constexpr static const uint32_t LEFTCURLY = '{';
|
||||
static const uint32_t LEFTCURLY = '{';
|
||||
|
||||
struct Foo {
|
||||
int32_t x;
|
||||
static const int64_t CONSTANT_I64_BODY;
|
||||
};
|
||||
constexpr inline const int64_t Foo::CONSTANT_I64_BODY = 216;
|
||||
inline const int64_t Foo::CONSTANT_I64_BODY = 216;
|
||||
|
||||
constexpr static const Foo SomeFoo = Foo{ /* .x = */ 99 };
|
||||
static const Foo SomeFoo = Foo{ /* .x = */ 99 };
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const uint8_t A = 0;
|
||||
constexpr static const uint8_t A = 0;
|
||||
|
||||
static const uint8_t B = 0;
|
||||
constexpr static const uint8_t B = 0;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const uint8_t B = 0;
|
||||
constexpr static const uint8_t B = 0;
|
||||
|
||||
static const uint8_t A = 0;
|
||||
constexpr static const uint8_t A = 0;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ struct S {
|
||||
|
||||
using A = uint8_t;
|
||||
|
||||
static const S C1 = S{ /* .field = */ 0 };
|
||||
constexpr static const S C1 = S{ /* .field = */ 0 };
|
||||
|
||||
static const E C2 = V;
|
||||
constexpr static const E C2 = V;
|
||||
|
||||
static const A C3 = 0;
|
||||
constexpr static const A C3 = 0;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const int8_t FOURTY_FOUR = 4;
|
||||
constexpr static const int8_t FOURTY_FOUR = 4;
|
||||
|
||||
enum class E : int8_t {
|
||||
A = 1,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const uint8_t EXPORT_ME_TOO = 42;
|
||||
constexpr static const uint8_t EXPORT_ME_TOO = 42;
|
||||
|
||||
struct ExportMe {
|
||||
uint64_t val;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const uint8_t EXPORT_ME_TOO = 42;
|
||||
constexpr static const uint8_t EXPORT_ME_TOO = 42;
|
||||
|
||||
struct ExportMe {
|
||||
uint64_t val;
|
||||
|
||||
@@ -11,11 +11,11 @@ DEF BAR = 0
|
||||
#include <new>
|
||||
|
||||
#if defined(FOO)
|
||||
static const int32_t FOO = 1;
|
||||
constexpr static const int32_t FOO = 1;
|
||||
#endif
|
||||
|
||||
#if defined(BAR)
|
||||
static const int32_t BAR = 2;
|
||||
constexpr static const int32_t BAR = 2;
|
||||
#endif
|
||||
|
||||
#if defined(FOO)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const uint8_t EXPORT_ME_TOO = 42;
|
||||
constexpr static const uint8_t EXPORT_ME_TOO = 42;
|
||||
|
||||
struct ExportMe {
|
||||
uint64_t val;
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
namespace constants {
|
||||
|
||||
static const int32_t FOO = 10;
|
||||
constexpr static const int32_t FOO = 10;
|
||||
|
||||
static const float ZOM = 3.14;
|
||||
constexpr static const float ZOM = 3.14;
|
||||
|
||||
struct Foo {
|
||||
int32_t x[FOO];
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
namespace constants {
|
||||
namespace test {
|
||||
|
||||
static const int32_t FOO = 10;
|
||||
constexpr static const int32_t FOO = 10;
|
||||
|
||||
static const float ZOM = 3.14;
|
||||
constexpr static const float ZOM = 3.14;
|
||||
|
||||
struct Foo {
|
||||
int32_t x[FOO];
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const int32_t PREFIX_LEN = 22;
|
||||
constexpr static const int32_t PREFIX_LEN = 22;
|
||||
|
||||
static const int64_t PREFIX_X = (22 << 22);
|
||||
constexpr static const int64_t PREFIX_X = (22 << 22);
|
||||
|
||||
static const int64_t PREFIX_Y = (PREFIX_X + PREFIX_X);
|
||||
constexpr static const int64_t PREFIX_Y = (PREFIX_X + PREFIX_X);
|
||||
|
||||
using PREFIX_NamedLenArray = int32_t[PREFIX_LEN];
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ struct PREFIXFoo {
|
||||
int32_t a;
|
||||
uint32_t b;
|
||||
};
|
||||
static const PREFIXFoo PREFIXFoo_FOO = PREFIXFoo{ /* .a = */ 42, /* .b = */ 47 };
|
||||
constexpr static const PREFIXFoo PREFIXFoo_FOO = PREFIXFoo{ /* .a = */ 42, /* .b = */ 47 };
|
||||
|
||||
static const PREFIXFoo PREFIXBAR = PREFIXFoo{ /* .a = */ 42, /* .b = */ 1337 };
|
||||
constexpr static const PREFIXFoo PREFIXBAR = PREFIXFoo{ /* .a = */ 42, /* .b = */ 1337 };
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ struct PREFIXFoo {
|
||||
PREFIXBar bar;
|
||||
};
|
||||
|
||||
static const PREFIXFoo PREFIXVAL = PREFIXFoo{ /* .a = */ 42, /* .b = */ 1337, /* .bar = */ PREFIXBar{ /* .a = */ 323 } };
|
||||
constexpr static const PREFIXFoo PREFIXVAL = PREFIXFoo{ /* .a = */ 42, /* .b = */ 1337, /* .bar = */ PREFIXBar{ /* .a = */ 323 } };
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const int32_t C_H = 10;
|
||||
constexpr static const int32_t C_H = 10;
|
||||
|
||||
enum class C_E : uint8_t {
|
||||
x = 0,
|
||||
|
||||
@@ -10,12 +10,12 @@ struct Foo {
|
||||
int32_t a;
|
||||
uint32_t b;
|
||||
};
|
||||
static const Foo Foo_FOO = Foo{ /* .a = */ 42, /* .b = */ 47 };
|
||||
static const Foo Foo_FOO2 = Foo{ /* .a = */ 42, /* .b = */ 47 };
|
||||
static const Foo Foo_FOO3 = Foo{ /* .a = */ 42, /* .b = */ 47 };
|
||||
constexpr static const Foo Foo_FOO = Foo{ /* .a = */ 42, /* .b = */ 47 };
|
||||
constexpr static const Foo Foo_FOO2 = Foo{ /* .a = */ 42, /* .b = */ 47 };
|
||||
constexpr static const Foo Foo_FOO3 = Foo{ /* .a = */ 42, /* .b = */ 47 };
|
||||
|
||||
|
||||
static const Foo BAR = Foo{ /* .a = */ 42, /* .b = */ 1337 };
|
||||
constexpr static const Foo BAR = Foo{ /* .a = */ 42, /* .b = */ 1337 };
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,18 +9,18 @@ struct ABC {
|
||||
uint32_t b;
|
||||
uint32_t c;
|
||||
};
|
||||
static const ABC ABC_abc = ABC{ /* .a = */ 1.0, /* .b = */ 2, /* .c = */ 3 };
|
||||
static const ABC ABC_bac = ABC{ /* .a = */ 1.0, /* .b = */ 2, /* .c = */ 3 };
|
||||
static const ABC ABC_cba = ABC{ /* .a = */ 1.0, /* .b = */ 2, /* .c = */ 3 };
|
||||
constexpr static const ABC ABC_abc = ABC{ /* .a = */ 1.0, /* .b = */ 2, /* .c = */ 3 };
|
||||
constexpr static const ABC ABC_bac = ABC{ /* .a = */ 1.0, /* .b = */ 2, /* .c = */ 3 };
|
||||
constexpr static const ABC ABC_cba = ABC{ /* .a = */ 1.0, /* .b = */ 2, /* .c = */ 3 };
|
||||
|
||||
struct BAC {
|
||||
uint32_t b;
|
||||
float a;
|
||||
int32_t c;
|
||||
};
|
||||
static const BAC BAC_abc = BAC{ /* .b = */ 1, /* .a = */ 2.0, /* .c = */ 3 };
|
||||
static const BAC BAC_bac = BAC{ /* .b = */ 1, /* .a = */ 2.0, /* .c = */ 3 };
|
||||
static const BAC BAC_cba = BAC{ /* .b = */ 1, /* .a = */ 2.0, /* .c = */ 3 };
|
||||
constexpr static const BAC BAC_abc = BAC{ /* .b = */ 1, /* .a = */ 2.0, /* .c = */ 3 };
|
||||
constexpr static const BAC BAC_bac = BAC{ /* .b = */ 1, /* .a = */ 2.0, /* .c = */ 3 };
|
||||
constexpr static const BAC BAC_cba = BAC{ /* .b = */ 1, /* .a = */ 2.0, /* .c = */ 3 };
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ template<typename T>
|
||||
using TransparentPrimitiveWrapper = uint32_t;
|
||||
|
||||
using TransparentPrimitiveWithAssociatedConstants = uint32_t;
|
||||
static const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ZERO = 0;
|
||||
static const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ONE = 1;
|
||||
constexpr static const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ZERO = 0;
|
||||
constexpr static const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ONE = 1;
|
||||
|
||||
static const TransparentPrimitiveWrappingStructure EnumWithAssociatedConstantInImpl_TEN = 10;
|
||||
constexpr static const TransparentPrimitiveWrappingStructure EnumWithAssociatedConstantInImpl_TEN = 10;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
static const int32_t EXT_CONST = 0;
|
||||
constexpr static const int32_t EXT_CONST = 0;
|
||||
|
||||
struct ExtType {
|
||||
uint32_t data;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[const]
|
||||
allow_constexpr = true
|
||||
allow_constexpr = false
|
||||
|
||||
[struct]
|
||||
associated_constants_in_body = true
|
||||
|
||||
Reference in New Issue
Block a user