Skip to content

Commit

Permalink
Ignore typeless structs in unstructured annotations
Browse files Browse the repository at this point in the history
This pass expects struct expressions in unstructured annotations to have
explicit types. Using { } in unstructured annotation is actually allowed
by the language spec, it does not make sense for the frontend to prevent
this (in fact any sequence of tokens can be used as long as parentheses
are balanced). nvp4c will need to use untyped struct expressions in this
context to allow the user to provide values for the fields of headers.

Signed-off-by: Chris Dodd <[email protected]>
  • Loading branch information
Emre Orbay authored and ChrisDodd committed Dec 9, 2024
1 parent 650af7e commit d247542
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontends/p4/specializeGenericTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ const IR::Node *ReplaceTypeUses::postorder(IR::Type_Specialized *type) {
}

const IR::Node *ReplaceTypeUses::postorder(IR::StructExpression *expression) {
const IR::Annotation *anNode = findContext<IR::Annotation>();
if (anNode != nullptr && !anNode->structured) return expression;

auto st = getOriginal<IR::StructExpression>()->structType;
if (!st) {
::P4::error(ErrorType::ERR_TYPE_ERROR,
Expand Down

0 comments on commit d247542

Please sign in to comment.