Drop assign_array macro

The macro is no longer necessary: the code now ensures we never
need to assign anything to an array, which would be ill-advised
nevertheless given that array-typed rvalues in C immediately
decay to pointers.
This commit is contained in:
Pietro Fezzardi
2026-05-08 11:37:10 +02:00
parent 85a9780d28
commit 58e95d330f
3 changed files with 1 additions and 38 deletions
-27
View File
@@ -489,26 +489,6 @@ public:
Tokens.emitOperator(getOperator(Op));
}
RecursiveCoroutine<void> emitAssignMacroExpression(mlir::Value V) {
auto Assign = V.getDefiningOp<AssignOp>();
auto LHS = Assign.getOperand(0);
auto RHS = Assign.getOperand(1);
Tokens.emitLiteralIdentifier("assign_array");
Tokens.emitPunctuator(CTE::Punctuator::LeftParenthesis);
rc_recur emitExpression(LHS);
Tokens.emitPunctuator(CTE::Punctuator::Comma);
Tokens.emitSpace();
CurrentPrecedence = OperatorPrecedence::Parentheses;
rc_recur emitExpression(RHS);
Tokens.emitPunctuator(CTE::Punctuator::RightParenthesis);
}
RecursiveCoroutine<void> emitInfixExpression(mlir::Value V) {
mlir::Operation *Op = V.getDefiningOp();
@@ -744,13 +724,6 @@ public:
if (auto Assign = V.getDefiningOp<AssignOp>()) {
auto LHS = Assign.getOperand(0);
auto RHS = Assign.getOperand(1);
if (isa<clift::ArrayType>(LHS.getType())
or isa<clift::ArrayType>(RHS.getType())) {
return {
.Precedence = OperatorPrecedence::UnaryPostfix,
.Emit = &CliftToCEmitter::emitAssignMacroExpression,
};
}
return {
.Precedence = OperatorPrecedence::Assignment,
.Emit = &CliftToCEmitter::emitInfixExpression,
-1
View File
@@ -324,7 +324,6 @@ const std::set<llvm::StringRef> ReservedKeywords = {
"__typeof__",
"bit_cast",
"static_assert_typedef",
"assign_array",
};
/// Returns `true` iff the identifier is exactly the given prefix + a decimal
+1 -10
View File
@@ -232,7 +232,7 @@ extern uintmax_t undef_value(void);
//
// __typeof__ is required for properly implementing a generic bitcast primitive
// and a generic array_assignment primitive that only need the destination type.
// that only needs the destination type.
#if defined(__GNUC__) // For Clang and GCC, they both have __typeof__
// Don't do anything, __typeof__ is already available
#elif __STDC_VERSION__ >= 202311L // C23 has typeof
@@ -274,12 +274,3 @@ extern uintmax_t undef_value(void);
.dst)
#endif // defined(__GNU_C_)
//
// array_assign and array_bit_cast
//
#define assign_array(x, ...) \
(*(__typeof__(x) *) __builtin_memcpy(&(x), \
&((__VA_ARGS__)), \
sizeof(__typeof__(x))))