Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/Dialect/FIRRTL/Import/FIRParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2691,11 +2691,27 @@ ParseResult FIRStmtParser::parseCatExp(Value &result) {

auto loc = getToken().getLoc();
SmallVector<Value, 3> operands;
std::optional<bool> isSigned;
if (parseListUntil(FIRToken::r_paren, [&]() -> ParseResult {
Value operand;
locationProcessor.setLoc(loc);
auto operandLoc = getToken().getLoc();
if (parseExp(operand, "expected expression in cat expression"))
return failure();
if (!type_isa<IntType>(operand.getType())) {
auto diag = emitError(loc, "all operands must be Int type");
diag.attachNote(translateLocation(operandLoc))
<< "non-integer operand is here";
return failure();
}
if (!isSigned)
isSigned = type_isa<SIntType>(operand.getType());
else if (type_isa<SIntType>(operand.getType()) != *isSigned) {
auto diag = emitError(loc, "all operands must have same signedness");
diag.attachNote(translateLocation(operandLoc))
<< "operand with different signedness is here";
return failure();
}

operands.push_back(operand);
return success();
Expand Down
19 changes: 19 additions & 0 deletions test/Dialect/FIRRTL/parse-errors.fir
Original file line number Diff line number Diff line change
Expand Up @@ -1825,3 +1825,22 @@ circuit ExtModuleKnownLayerSpecMissing2ndLayerName:
layer A, bind:
; expected-error @below {{expected layer name}}
extmodule ExtModuleKnownLayerSpecMissing2ndLayerName knownlayer A,:

// -----
FIRRTL version 6.0.0
circuit CatSign:
public module CatExp:
; expected-error @below {{all operands must have same signedness}}
node n = cat(UInt<1>(0),
; expected-note @below {{operand with different signedness is here}}
SInt<1>(0))

// -----
FIRRTL version 6.0.0
circuit CatSign:
public module CatExp:
input a: UInt<1>[1]
; expected-error @below {{all operands must be Int type}}
node n = cat(UInt<1>(0),
; expected-note @below {{non-integer operand is here}}
a)