Skip to content

Commit

Permalink
some more invalid tests and tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
ghehg committed Sep 13, 2024
1 parent c192b0b commit 03fc0aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ void MethodAttr::print(AsmPrinter &printer) const {
//===----------------------------------------------------------------------===//
// GlobalAnnotationValuesAttr definitions
//===----------------------------------------------------------------------===//

LogicalResult GlobalAnnotationValuesAttr::verify(
function_ref<::mlir::InFlightDiagnostic()> emitError,
mlir::ArrayAttr annotations) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,7 @@ class CIRGlobalOpLowering
// Rewrite op.
auto llvmGlobalOp = rewriter.replaceOpWithNewOp<mlir::LLVM::GlobalOp>(
op, llvmType, isConst, linkage, symbol, init.value(),
/*alignment*/op.getAlignment().value_or(0),
/*alignment*/ op.getAlignment().value_or(0),
/*addrSpace*/ getGlobalOpTargetAddrSpace(op),
/*dsoLocal*/ false, /*threadLocal*/ (bool)op.getTlsModelAttr(),
/*comdat*/ mlir::SymbolRefAttr(), attributes);
Expand Down
7 changes: 7 additions & 0 deletions clang/test/CIR/IR/invalid-annotations.cir
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// Test attempt to construct ill-formed global annotations
// RUN: cir-opt %s -verify-diagnostics -split-input-file


// expected-error @below {{invalid kind of attribute specified}}
// expected-error @below {{failed to parse AnnotationAttr parameter 'name' which is to be a `StringAttr`}}
cir.global external @a = #cir.ptr<null> : !cir.ptr<!cir.double> [#cir.annotation<name = 18, args = ["21", 12 : i32]>]

// -----

// expected-error @below {{GlobalAnnotationValuesAttr should at least have one annotation}}
module attributes {cir.global_annotations = #cir<annotation_values []>} {}

Expand Down

0 comments on commit 03fc0aa

Please sign in to comment.