Clean up the clone() code a bit

This commit is contained in:
Justine Tunney 2022-05-17 07:40:00 -07:00
parent ce71677156
commit 2743f3d012
20 changed files with 252 additions and 150 deletions

View file

@ -559,6 +559,7 @@ static Token *thing_attributes(Token *tok, void *arg) {
consume_attribute(&tok, tok, "warn_unused_result") ||
consume_attribute(&tok, tok, "flatten") ||
consume_attribute(&tok, tok, "leaf") ||
consume_attribute(&tok, tok, "no_reorder") ||
consume_attribute(&tok, tok, "dontthrow") ||
consume_attribute(&tok, tok, "optnone") ||
consume_attribute(&tok, tok, "returns_twice") ||

View file

@ -1174,6 +1174,14 @@ __INT_FAST32_TYPE__\000\
int\000\
__UINT_FAST32_TYPE__\000\
unsigned\000\
__INT_FAST8_MAX__\000\
0x7f\000\
__INT_FAST16_MAX__\000\
0x7fffffff\000\
__INT_FAST32_MAX__\000\
0x7fffffff\000\
__INT_FAST64_MAX__\000\
0x7fffffffffffffffl\000\
__INT_FAST64_TYPE__\000\
long\000\
__UINT_FAST64_TYPE__\000\

View file

@ -1,3 +1,4 @@
#include "libc/assert.h"
#include "third_party/chibicc/chibicc.h"
/* TODO(jart): Why can't these be const? */
@ -144,6 +145,9 @@ static Type *get_common_type(Type *ty1, Type *ty2) {
//
// This operation is called the "usual arithmetic conversion".
static void usual_arith_conv(Node **lhs, Node **rhs) {
if (!(*lhs)->ty || !(*rhs)->ty) {
error_tok((*lhs)->tok, "internal npe error");
}
Type *ty = get_common_type((*lhs)->ty, (*rhs)->ty);
*lhs = new_cast(*lhs, ty);
*rhs = new_cast(*rhs, ty);