Skip to content

Commit

Permalink
Add two related tests, add comments with PR link to the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vlstill committed Feb 13, 2024
1 parent ef57382 commit 5fadbaa
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
9 changes: 9 additions & 0 deletions testdata/p4_16_errors/type-in-expr-lex0.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// tests problems related to https://github.com/p4lang/p4c/pull/4411

#include <core.p4>

control ctrl<H>(bool val);

package pkg<H>(
ctrl<H> val = ctrl(H > 3)
);
10 changes: 10 additions & 0 deletions testdata/p4_16_errors/type-in-expr-lex1.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// tests problems related to https://github.com/p4lang/p4c/pull/4411

#include <core.p4>

parser pars<H>(in bit<16> buf, out H hdrs) {
bool var;
state start {
var = buf > H;
}
}
2 changes: 2 additions & 0 deletions testdata/p4_16_errors/type-in-expr.p4
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// tests problem solved by https://github.com/p4lang/p4c/pull/4411

#include <core.p4>

@foo[bar=4<H]
Expand Down
4 changes: 4 additions & 0 deletions testdata/p4_16_errors_outputs/type-in-expr-lex0.p4-stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type-in-expr-lex0.p4(8):syntax error, unexpected >, expecting (
ctrl<H> val = ctrl(H >
^
[--Werror=overlimit] error: 1 errors encountered, aborting compilation
4 changes: 4 additions & 0 deletions testdata/p4_16_errors_outputs/type-in-expr-lex1.p4-stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type-in-expr-lex1.p4(8):syntax error, unexpected ;, expecting (
var = buf > H;
^
[--Werror=overlimit] error: 1 errors encountered, aborting compilation
8 changes: 4 additions & 4 deletions testdata/p4_16_errors_outputs/type-in-expr.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
type-in-expr.p4(3): [--Werror=type-error] error: H: Type cannot be used here, expecting an expression.
type-in-expr.p4(5): [--Werror=type-error] error: H: Type cannot be used here, expecting an expression.
@foo[bar=4<H]
^
type-in-expr.p4(3): [--Werror=type-error] error: 4 < H: structured annotation must be compile-time constant values
type-in-expr.p4(5): [--Werror=type-error] error: 4 < H: structured annotation must be compile-time constant values
@foo[bar=4<H]
^^^
type-in-expr.p4(3): [--Werror=type-error] error: H: Type cannot be used here, expecting an expression.
type-in-expr.p4(5): [--Werror=type-error] error: H: Type cannot be used here, expecting an expression.
@foo[bar=4<H]
^
type-in-expr.p4(4): [--Werror=type-error] error: Error while analyzing control p
type-in-expr.p4(6): [--Werror=type-error] error: Error while analyzing control p
control p<H>(in H hdrs, out bool flag)
^

0 comments on commit 5fadbaa

Please sign in to comment.