20class ValidateMatchAnnotations final :
public Inspector {
24 explicit ValidateMatchAnnotations(
TypeMap *typeMap) : typeMap(typeMap) {
25 setName(
"ValidateMatchAnnotations");
27 void postorder(
const IR::Annotation *annotation)
override {
28 if (annotation->name != IR::Annotation::matchAnnotation)
return;
29 if (!isInContext<IR::StructField>())
return;
31 const auto &expr = annotation->getExpr();
33 ::P4::error(ErrorType::ERR_INVALID,
"%1%: annotation must have exactly 1 argument",
36 auto type = typeMap->getType(e0,
true);
37 if (type ==
nullptr)
return;
38 if (!type->is<IR::Type_MatchKind>())
39 ::P4::error(ErrorType::ERR_TYPE_ERROR,
"%1%: value must be a match_kind", e0);
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13
void error(const char *format, Args &&...args)
Report an error with the given message.
Definition lib/error.h:58