diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp --- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp +++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp @@ -220,6 +220,11 @@ parser.emitError(loc) << "expected non empty string in !emitc.opaque type"; return Type(); } + if (value.find("*") != std::string::npos) { + parser.emitError(loc) + << "* not allowed in !emitc.opaque type, use !emitc.ptr instead"; + return Type(); + } if (parser.parseGreater()) return Type(); return get(parser.getContext(), value); diff --git a/mlir/test/Dialect/EmitC/invalid_types.mlir b/mlir/test/Dialect/EmitC/invalid_types.mlir --- a/mlir/test/Dialect/EmitC/invalid_types.mlir +++ b/mlir/test/Dialect/EmitC/invalid_types.mlir @@ -4,3 +4,10 @@ // expected-error @+1 {{expected non empty string in !emitc.opaque type}} %1 = "emitc.variable"(){value = "42" : !emitc.opaque<"">} : () -> !emitc.opaque<"mytype"> } + +// ----- + +func @illegal_opaque_type_2() { + // expected-error @+1 {{* not allowed in !emitc.opaque type, use !emitc.ptr instead}} + %1 = "emitc.variable"(){value = "nullptr" : !emitc.opaque<"int32_t*">} : () -> !emitc.opaque<"int32_t*"> +}