aboutsummaryrefslogtreecommitdiff
path: root/eval.c
AgeCommit message (Collapse)Author
2024-04-27Store enum constant value in struct declMichael Forney
2024-04-21expr: Create decl for compound literal during parseMichael Forney
2024-04-20qbe: Pass struct decl to mkglobal instead of fields from the declMichael Forney
2024-04-19implement _Thread_local storage classDrew DeVault
Implements: https://todo.sr.ht/~mcf/cproc/8
2024-04-12decl: Add name field to decl structMichael Forney
2024-04-07eval: Use enum instead of define for float/signed flagsMichael Forney
2024-04-02map: Use simpler fnv-1a hash functionMichael Forney
2024-03-23expr: Keep track of storage duration of compound literalsMichael Forney
2022-05-19eval: Fix range check of double during conversion to intMichael Forney
2⁶⁴-1 and 2⁶³-1 are not representable as double and get rounded to 2⁶⁴ and 2⁶³ respectively, which are outside the range of 64-bit [u]int. This causes undefined behavior when a constant expression is evaluated that involves a conversion of a very large or small value to an integer type. To fix this, change the > to >= and use constants representable as double.
2022-01-22Handle unary minus specially instead of 0 - xMichael Forney
This is necessary to fix unary negation of floating-point 0 (also depends on a pending qbe patch).
2022-01-22Remove most usage of fixed-width integer typesMichael Forney
We only require a type of at least 64 bits, so just use unsigned long long. Only siphash remains as the last user of uint64_t.
2022-01-22eval: Simplify sign/zero extensionMichael Forney
2022-01-22Port to C99Michael Forney
2021-10-25eval: Fix int-to-float conversionsMichael Forney
Also, add bounds checks for float-to-int conversions. If the integer part can't be represented in the result type, C behavior is undefined. Although this means the result is arbitrary, we need to avoid undefined behavior in cproc itself when given such a program as input.
2021-09-29eval: Allow subtraction in address constantsMichael Forney
2021-09-29eval: Avoid implementation-defined unsigned to signed conversionsMichael Forney
Instead, use an additional int64_t member in the union. Since exact-width integer types have no padding bits or trap representations, and use two's-complement representation, we can portably access an int64_t union member stored as uint64_t and vice-versa. This allows us to reinterpret the value without invoking potentially implementation-defined behavior of casting an unsigned integer to a signed integer type which may not be able to represent its value.
2021-09-29Rename uint64_t field of constant union to uMichael Forney
This will prepare us for adding a signed int64_t field called i.
2021-09-29eval: Remove now unneeded handling of EXPRCONDMichael Forney
We now do this evaluation during parsing.
2020-01-31eval: Allow casting address constants to integer types in constant expressionsMichael Forney
2019-05-19eval: Collapse & and * operators in integer constant expressionsMichael Forney
They might be used to implement offsetof.
2019-05-12eval: Keep track of kind of constant expression we are evaluatingMichael Forney
When we are evaluating an arithmetic constant expression, we don't want to indroduce static data definitions for string or compound literals. Fixes #59.
2019-04-24Use a common member for expression baseMichael Forney
2019-04-24Use a common member for expression opMichael Forney
2019-04-24eval: Check that expression has integer type before checking if it's signedMichael Forney
It could be an integer constant cast to a pointer type.
2019-04-21Keep track of type properties in typeMichael Forney
2019-04-20eval: Handle casts in constant expressionsMichael Forney
Fixes #23.
2019-04-06Separate unqualified type and qualifiers in struct declMichael Forney
2019-04-06Separate unqualified type and qualifiers in struct exprMichael Forney
2019-04-04Merge headers into cc.hMichael Forney
2019-03-14Abbreviate tag namesMichael Forney
2019-02-20Remove some unused variablesMichael Forney
2019-02-20eval: Handle nested offset address constantsMichael Forney
2019-02-15Fix backwards constant evaluation of float-int castsMichael Forney
2019-02-15Rename emit.h -> backend.hMichael Forney
2019-02-14Handle compound literals in global initializersMichael Forney
2019-02-12Initial importMichael Forney