52 return (
int)_val < 0 ? -1 : 1;
56 return (
long)_val < 0L ? -1 : 1;
60 return (
long long)_val < 0LL ? -1 : 1;
75 if (result != lhs.
_type) {
77 result = to_unsigned(result);
82 string converted =
citable(test);
84 " changed to " << converted <<
85 " by the usual arithmetic conversions" <<
emit();
87 }
else if (result != rhs.
_type) {
89 result = to_unsigned(result);
94 string converted =
citable(test);
96 " changed to " << converted <<
97 " by the usual arithmetic conversions" <<
emit();
108 size_t type_bits = lhs.
size() * 8;
109 unsigned long long val = rhs.
raw();
111 unsigned long long neg_bit = (
unsigned long long)1 << (type_bits - 1);
113 char const * way = direction < 0 ?
"left" :
"right";
115 "-shift has undefined behavior. "
116 "The expression will not be resolved" <<
emit();
120 if (ok && val >= type_bits) {
123 <<
" by " << type_bits <<
" bits has undefined behavior. "
141 (
unsigned long)_val < (
unsigned long)rhs.
raw());
146 (
unsigned long long)_val < (
unsigned long long)rhs.
raw());
164 (
unsigned long)_val <= (
unsigned long)rhs.
raw());
169 (
unsigned long long)_val <= (
unsigned long long)rhs.
raw());
187 (
unsigned long)_val > (
unsigned long)rhs.
raw());
192 (
unsigned long long)_val > (
unsigned long long)rhs.
raw());
210 (
unsigned long)_val >= (
unsigned long)rhs.
raw());
215 (
unsigned long long)_val >= (
unsigned long long)rhs.
raw());
233 (
unsigned long)_val != (
unsigned long)rhs.
raw());
238 (
unsigned long long)_val != (
unsigned long long)rhs.
raw());
256 (
unsigned long)_val == (
unsigned long)rhs.
raw());
261 (
unsigned long long)_val == (
unsigned long long)rhs.
raw());
279 (
unsigned long)_val && (
unsigned long)rhs.
raw());
284 (
unsigned long long)_val && (
unsigned long long)rhs.
raw());
302 (
unsigned long)_val || (
unsigned long)rhs.
raw());
307 (
unsigned long long)_val || (
unsigned long long)rhs.
raw());
325 (
unsigned long)_val & (
unsigned long)rhs.
raw());
330 (
unsigned long long)_val & (
unsigned long long)rhs.
raw());
348 (
unsigned long)_val | (
unsigned long)rhs.
raw());
353 (
unsigned long long)_val | (
unsigned long long)rhs.
raw());
371 (
unsigned long)_val ^ (
unsigned long)rhs.
raw());
376 (
unsigned long long)_val ^ (
unsigned long long)rhs.
raw());
386 return integer(_type,-(
int)_val);
388 return integer(_type,-(
unsigned)_val);
390 return integer(_type,-(
long)_val);
392 return integer(_type,-(
unsigned long)_val);
394 return integer(_type,-(
long long)_val);
396 return integer(_type,-(
unsigned long long)_val);
406 return integer(_type,~(
int)_val);
408 return integer(_type,~(
unsigned)_val);
410 return integer(_type,~(
long)_val);
412 return integer(_type,~(
unsigned long)_val);
414 return integer(_type,~(
long long)_val);
416 return integer(_type,~(
unsigned long long)_val);
427 return integer(type,(
int)_val + (
int)rhs.
raw());
429 return integer(type,(
unsigned)_val + (
unsigned)rhs.
raw());
431 return integer(type,(
long)_val + (
long)rhs.
raw());
434 (
unsigned long)_val + (
unsigned long)rhs.
raw());
436 return integer(type,(
long long)_val + (
long long)rhs.
raw());
439 (
unsigned long long)_val + (
unsigned long long)rhs.
raw());
450 return integer(type,(
int)_val - (
int)rhs.
raw());
452 return integer(type,(
unsigned)_val - (
unsigned)rhs.
raw());
454 return integer(type,(
long)_val - (
long)rhs.
raw());
457 (
unsigned long)_val - (
unsigned long)rhs.
raw());
459 return integer(type,(
long long)_val - (
long long)rhs.
raw());
462 (
unsigned long long)_val - (
unsigned long long)rhs.
raw());
473 return integer(type,(
int)_val * (
int)rhs.
raw());
475 return integer(type,(
unsigned)_val * (
unsigned)rhs.
raw());
477 return integer(type,(
long)_val * (
long)rhs.
raw());
480 (
unsigned long)_val * (
unsigned long)rhs.
raw());
482 return integer(type,(
long long)_val * (
long long)rhs.
raw());
485 (
unsigned long long)_val * (
unsigned long long)rhs.
raw());
496 return integer(type,(
int)_val / (
int)rhs.
raw());
498 return integer(type,(
unsigned)_val / (
unsigned)rhs.
raw());
500 return integer(type,(
long)_val / (
long)rhs.
raw());
503 (
unsigned long)_val / (
unsigned long)rhs.
raw());
505 return integer(type,(
long long)_val / (
long long)rhs.
raw());
508 (
unsigned long long)_val / (
unsigned long long)rhs.
raw());
519 return integer(type,(
int)_val % (
int)rhs.
raw());
521 return integer(type,(
unsigned)_val % (
unsigned)rhs.
raw());
523 return integer(type,(
long)_val % (
long)rhs.
raw());
526 (
unsigned long)_val % (
unsigned long)rhs.
raw());
528 return integer(type,(
long long)_val % (
long long)rhs.
raw());
531 (
unsigned long long)_val % (
unsigned long long)rhs.
raw());
545 return integer(_type,(
int)_val << (
int)rhs.
raw());
547 return integer(_type,(
unsigned)_val << (
unsigned)rhs.
raw());
549 return integer(_type,(
long)_val << (
long)rhs.
raw());
552 (
unsigned long)_val << (
unsigned long)rhs.
raw());
554 return integer(_type,(
long long)_val << (
long long)rhs.
raw());
557 (
unsigned long long)_val << (
unsigned long long)rhs.
raw());
566 if (type_check ==
INT_UNDEF || !valid_shift(1,*
this,rhs)) {
571 return integer(_type,(
int)_val >> (
int)rhs.
raw());
573 return integer(_type,(
unsigned)_val >> (
unsigned)rhs.
raw());
575 return integer(_type,(
long)_val >> (
long)rhs.
raw());
578 (
unsigned long)_val >> (
unsigned long)rhs.
raw());
580 return integer(_type,(
long long)_val >> (
long long)rhs.
raw());
583 (
unsigned long long)_val >> (
unsigned long long)rhs.
raw());
595 return "unsigned int";
599 return "unsigned long int";
601 return "long long int";
603 return "unsigned long long int";
static integer_type result_type(integer const &lhs, integer const &rhs)
unsigned long long raw() const
Get the bits comprising the integer as an unsigned long long
integer operator&&(integer const &rhs) const
size_t size() const
Get the size of the integer
integer operator>(integer const &rhs) const
integer operator<(integer const &rhs) const
integer operator*(integer const &rhs) const
integer_type _type
The type of the integer.
warning_msg< 23 > warning_shift_overflow
Report a that shift count is >= the width of the shifted quantity.
integer operator^(integer const &rhs) const
Undetermined type or invalid.
Class integer encapsulates an integer of some type.
integer operator>=(integer const &rhs) const
std::string citable(chewer< std::string > &chew, size_t len=std::string::npos)
Make a citable version of length-delimited text.
integer operator+() const
warning_msg< 20 > warning_negative_shift
Report negative shift count.
integer operator-() const
static bool valid_shift(int direction, integer const &lhs, integer const &rhs)
char const * type_desc() const
Get the text descriptor of this integer's type.
integer_type
Enumerated constants denoting integral types.
The tag class is inserted in a diagnostic_base to tell it to emit itself.
warning_msg< 22 > warning_sign_changed
Report integer sign changed by promotion.
integer operator/(integer const &rhs) const
integer operator~() const
integer operator==(integer const &rhs) const
unsigned long long _val
The value of the integer
integer operator<=(integer const &rhs) const
unsigned rank() const
Get the conversion rank of an integer
integer_type type() const
Get the type of the integer
integer operator<<(integer const &rhs) const
integer operator|(integer const &rhs) const
integer operator&(integer const &rhs) const
integer operator>>(integer const &rhs) const
integer operator!=(integer const &rhs) const
integer operator%(integer const &rhs) const
integer operator||(integer const &rhs) const
bool is_signed() const
Say whether the integer is of signed type.