Skip to content

Commit

Permalink
update expected error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Dodd committed Aug 14, 2023
1 parent 9209776 commit e819dc4
Show file tree
Hide file tree
Showing 33 changed files with 65 additions and 62 deletions.
2 changes: 1 addition & 1 deletion testdata/p4_14_errors_outputs/issue905.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
issue905.p4(34): [--Werror=type-error] error: *: not defined on operands of type varbit<0>
issue905.p4(34): [--Werror=type-error] error: can_data.value * 2: not defined on operands of type varbit<0>
modify_field(can_data.value, can_data.value * 2); // error
^
[--Werror=overlimit] error: 1 errors encountered, aborting compilation
6 changes: 3 additions & 3 deletions testdata/p4_16_errors_outputs/binary_e.p4-stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ binary_e.p4(32): [--Werror=type-error] error: Indexing a[2] applied to non-array
binary_e.p4(33): [--Werror=type-error] error: Array index d must be an integer, but it has type bool
c = stack[d]; // indexing with bool
^
binary_e.p4(35): [--Werror=type-error] error: &: Cannot operate on values with different widths 2 and 4
binary_e.p4(35): [--Werror=type-error] error: e & f: Cannot operate on values with different widths 2 and 4
f = e & f; // different width
^^^^^
binary_e.p4(38): [--Werror=type-error] error: <: not defined on bool and bool
binary_e.p4(38): [--Werror=type-error] error: d < d: not defined on bool and bool
d = d < d; // not defined on bool
^^^^^
binary_e.p4(39): [--Werror=type-error] error: >: not defined on int<2> and int<4>
binary_e.p4(39): [--Werror=type-error] error: a > c: not defined on int<2> and int<4>
d = a > c; // different width
^^^^^
4 changes: 2 additions & 2 deletions testdata/p4_16_errors_outputs/const1_e.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const1_e.p4(19): [--Werror=invalid] error: +: operands have different types: bit<32> and bit<16>
const1_e.p4(19): [--Werror=invalid] error: 5 + 3: operands have different types: bit<32> and bit<16>
x = 32w5 + 16w3;
^^^^^^^^^^^
const1_e.p4(21): [--Werror=invalid] error: /: Division by zero
const1_e.p4(21): [--Werror=invalid] error: 5 / 0: Division by zero
x = 5 / 0;
^^^^^
6 changes: 3 additions & 3 deletions testdata/p4_16_errors_outputs/div.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
div.p4(18): [--Werror=invalid] error: /: Division is not defined for negative numbers
div.p4(18): [--Werror=invalid] error: -8 / -2: Division is not defined for negative numbers
a = - 8 / -2;
^^^^^^^^
div.p4(19): [--Werror=invalid] error: %: Modulo is not defined for negative numbers
div.p4(19): [--Werror=invalid] error: -10 % 2: Modulo is not defined for negative numbers
a = -10 % 2;
^^^^^^^
div.p4(20): [--Werror=invalid] error: %: Modulo is not defined for negative numbers
div.p4(20): [--Werror=invalid] error: 10 % -2: Modulo is not defined for negative numbers
a = 10 % -2;
^^^^^^^
8 changes: 4 additions & 4 deletions testdata/p4_16_errors_outputs/div0.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
div0.p4(18): [--Werror=expr] error: /: Division by zero
div0.p4(18): [--Werror=expr] error: a / 0: Division by zero
a = a / 0;
^^^^^
div0.p4(19): [--Werror=expr] error: %: Modulo by zero
div0.p4(19): [--Werror=expr] error: a % 0: Modulo by zero
a = a % 0;
^^^^^
div0.p4(20): [--Werror=expr] error: /: Division by zero
div0.p4(20): [--Werror=expr] error: a / 0: Division by zero
a = a / 8w0;
^^^^^^^
div0.p4(21): [--Werror=expr] error: %: Modulo by zero
div0.p4(21): [--Werror=expr] error: a % 0: Modulo by zero
a = a % 8w0;
^^^^^^^
8 changes: 4 additions & 4 deletions testdata/p4_16_errors_outputs/div1.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
div1.p4(18): [--Werror=type-error] error: /: not defined on negative numbers
div1.p4(18): [--Werror=type-error] error: a / -1: not defined on negative numbers
a = a / -1; // not defined for negative numbers
^^^^^^
div1.p4(19): [--Werror=type-error] error: /: not defined on negative numbers
div1.p4(19): [--Werror=type-error] error: -5 / a: not defined on negative numbers
a = -5 / a;
^^^^^^
div1.p4(20): [--Werror=type-error] error: %: not defined on negative numbers
div1.p4(20): [--Werror=type-error] error: a % -1: not defined on negative numbers
a = a % -1;
^^^^^^
div1.p4(21): [--Werror=type-error] error: %: not defined on negative numbers
div1.p4(21): [--Werror=type-error] error: -5 % a: not defined on negative numbers
a = -5 % a;
^^^^^^
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/div3.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
div3.p4(19): [--Werror=invalid] error: /: could not evaluate expression at compilation time
div3.p4(19): [--Werror=invalid] error: a / 3: could not evaluate expression at compilation time
a = a / b; // not a compile-time constant
^^^^^
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/issue1542.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
issue1542.p4(27): [--Werror=type-error] error: cast: argument does not match declaration in actions list: cast
issue1542.p4(27): [--Werror=type-error] error: (bit<32>)32w2: argument does not match declaration in actions list: (bit<32>)32w1
( true, 1, true ) : multicast(2);
^
issue1542.p4(22)
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/issue2206.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
issue2206.p4(27): [--Werror=type-error] error: <<: width of left operand of shift needs to be specified
issue2206.p4(27): [--Werror=type-error] error: 1 << h.h.c: width of left operand of shift needs to be specified
h.h.a = (1 << h.h.c) + 8w2;
^^^^^^^^^^
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/issue2444-1.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
issue2444-1.p4(2): [--Werror=invalid] error: cast: Only 0 and 1 can be cast to booleans
issue2444-1.p4(2): [--Werror=invalid] error: (bool)2: Only 0 and 1 can be cast to booleans
const bool b1 = (bool)a1;
^^^^^^^^
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/issue2496.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
issue2496.p4(25): [--Werror=unsupported] error: <<: Compiler only supports widths up to 2048
issue2496.p4(25): [--Werror=unsupported] error: 1985245330 << 903012108: Compiler only supports widths up to 2048
h.eth_hdr.eth_type = 1985245330 << 903012108;
^^^^^^^^^^^^^^^^^^^^^^^
12 changes: 10 additions & 2 deletions testdata/p4_16_errors_outputs/issue3057-1.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
issue3057-1.p4(11): [--Werror=type-error] error: ==: cannot compare structure-valued expressions with unknown types
issue3057-1.p4(11): [--Werror=type-error] error: {
a:1;
b:2; } == {
a:1;
b:2; }: cannot compare structure-valued expressions with unknown types
bool b2 = {a = 32w1,b = 32w2} == {a = 32w1,b = 32w2};
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
issue3057-1.p4(12): [--Werror=type-error] error: ==: cannot compare structure-valued expressions with unknown types
issue3057-1.p4(12): [--Werror=type-error] error: {
a:1;
b:2; } == {
a:1;
b:2; }: cannot compare structure-valued expressions with unknown types
bool b2_ = {a = 1,b = 2} == {a = 1,b = 2};
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/issue3221.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
issue3221.p4(8): [--Werror=type-error] error: cast
issue3221.p4(8): [--Werror=type-error] error: (t1)a
return (t1)a;
^^^^^
---- Actual error:
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/issue401.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
issue401.p4(42): [--Werror=type-error] error: cast
issue401.p4(42): [--Werror=type-error] error: (bit<1>)ListExpression
bit<1> b = (bit<1>) { 0 };
^^^^^^^^^^^^^^
---- Actual error:
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/issue473.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
issue473.p4(70): [--Werror=type-error] error: cast: action argument must be a compile-time constant
issue473.p4(70): [--Werror=type-error] error: (bit<8>)meta.d: action argument must be a compile-time constant
default_action = b(meta.c, (bit<8>) meta.d);
^^^^^^^^^^^^^^^
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/key-name.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
key-name.p4(28): [--Werror=expected] error: +: Complex key expression requires a @name annotation
key-name.p4(28): [--Werror=expected] error: h.a + h.a: Complex key expression requires a @name annotation
key = { h.a + h.a : exact; }
^^^^^^^^^
4 changes: 2 additions & 2 deletions testdata/p4_16_errors_outputs/neg.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
neg.p4(21): [--Werror=type-error] error: /: Cannot operate on signed values
neg.p4(21): [--Werror=type-error] error: a / b: Cannot operate on signed values
c = a / b; // not defined for signed values
^^^^^
neg.p4(22): [--Werror=type-error] error: %: Cannot operate on signed values
neg.p4(22): [--Werror=type-error] error: a % b: Cannot operate on signed values
c = a % b;
^^^^^
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/newtype-err.p4-stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ newtype-err.p4(2): Cannot cast implicitly type 'bit<32>' to type 'N32'
type bit<32> N32;
^^^
---- Originating from:
newtype-err.p4(10): Source expression '+' produces a result of type 'bit<32>' which cannot be assigned to a left-value with type 'N32'
newtype-err.p4(10): Source expression 'b + b' produces a result of type 'bit<32>' which cannot be assigned to a left-value with type 'N32'
n = b + b;
^^^^^
newtype-err.p4(2)
Expand Down
15 changes: 5 additions & 10 deletions testdata/p4_16_errors_outputs/psa-meter2.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
psa-meter2.p4(57): [--Werror=type-error] error: cast
psa-meter2.p4(57): [--Werror=type-error] error: Cannot extract field GREEN from PSA_MeterColor_t which has type Type(PSA_MeterColor_t)
b.data = (bit<16>)meter0.execute(index, PSA_MeterColor_t.GREEN);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
---- Actual error:
psa.p4(631): Cannot unify type 'PSA_MeterColor_t' with type 'bit<16>'
enum PSA_MeterColor_t { RED, GREEN, YELLOW }
^^^^^^^^^^^^^^^^
---- Originating from:
psa.p4(631): Cannot cast from 'PSA_MeterColor_t' to 'bit<16>'
enum PSA_MeterColor_t { RED, GREEN, YELLOW }
^^^^^^^^^^^^^^^^
^^^^^
psa-meter2.p4(57)
b.data = (bit<16>)meter0.execute(index, PSA_MeterColor_t.GREEN);
^^^^^^^^^^^^^^^^
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/range_e.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
range_e.p4(20): [--Werror=type-error] error: ..: Cannot operate on values with different types bit<2> and bit<3>
range_e.p4(20): [--Werror=type-error] error: 2 .. 3: Cannot operate on values with different types bit<2> and bit<3>
2w2 .. 3w3 : reject; // different widths
^^^^^^^^^^
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/serenum-type.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
serenum-type.p4(8): [--Werror=type-error] error: EthT: Illegal type for enum; only bit<> and int<> are allowed
enum EthT EthTypes {
^^^^
serenum-type.p4(49): [--Werror=type-error] error: cast
serenum-type.p4(49): [--Werror=type-error] error: (EthTypes)16w0
h.eth.type = (EthTypes)(bit<16>)0;
^^^^^^^^^^^^^^^^^^^^
---- Actual error:
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/serenum-typedef.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
serenum-typedef.p4(8): [--Werror=type-error] error: EthT: Illegal type for enum; only bit<> and int<> are allowed
enum EthT EthTypes {
^^^^
serenum-typedef.p4(49): [--Werror=type-error] error: cast
serenum-typedef.p4(49): [--Werror=type-error] error: (EthTypes)16w0
h.eth.type = (EthTypes)(bit<16>)0;
^^^^^^^^^^^^^^^^^^^^
---- Actual error:
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/signs.p4-stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ signs.p4(18): [--Werror=type-error] error: b
signs.p4(18): Source expression '8w0' produces a result of type 'bit<8>' which cannot be assigned to a left-value with type 'int<8>'
int<8> b = 8w0;
^^^
signs.p4(19): [--Werror=type-error] error: -: Cannot operate on values with different signs
signs.p4(19): [--Werror=type-error] error: a - b: Cannot operate on values with different signs
a = a - b;
^^^^^
4 changes: 2 additions & 2 deletions testdata/p4_16_errors_outputs/table-entries-lpm-2.p4-stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ table-entries-lpm-2.p4(82): [--Wwarn=mismatch] warning: 8w0x100: value does not
table-entries-lpm-2.p4(71): [--Wwarn=mismatch] warning: P4Runtime requires that LPM matches have masked-off bits set to 0, updating value 8w0x11 to conform to the P4Runtime specification
0x11 &&& 0x1F0 : a_with_control_params(12);
^^^^
table-entries-lpm-2.p4(74): [--Werror=invalid] error: &&& invalid mask for LPM key
table-entries-lpm-2.p4(74): [--Werror=invalid] error: 17 &&& 225 invalid mask for LPM key
0x11 &&& 0xE1 : a_with_control_params(13);
^^^^^^^^^^^^^
table-entries-lpm-2.p4(78): [--Werror=invalid] error: &&& invalid mask for LPM key
table-entries-lpm-2.p4(78): [--Werror=invalid] error: 17 &&& 129 invalid mask for LPM key
0x11 &&& 0x181 : a_with_control_params(14);
^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ table-entries-optional-2-bmv2.p4(71): [--Wwarn=mismatch] warning: 8w0x100: value
table-entries-optional-2-bmv2.p4(73): [--Wwarn=mismatch] warning: 16w0x10000: value does not fit in 16 bits
(default, 0x10000): a_with_control_params(3);
^^^^^^^
table-entries-optional-2-bmv2.p4(69): [--Werror=invalid] error: &&& invalid key expression
table-entries-optional-2-bmv2.p4(69): [--Werror=invalid] error: 170 &&& 240 invalid key expression
(0xaa &&& 0xf0, 0x1111 &&& 0xffff) : a_with_control_params(1);
^^^^^^^^^^^^^
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/tuple-newtype.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tuple-newtype.p4(5): [--Werror=type-error] error: T: `type' can only be applied to base types
type tuple<bit> T;
^
tuple-newtype.p4(12): [--Werror=type-error] error: cast: Illegal cast from tuple<bit<1>> to T
tuple-newtype.p4(12): [--Werror=type-error] error: (T)ListExpression: Illegal cast from tuple<bit<1>> to T
T tt2 = (T){1w0};
^^^^^^^^
4 changes: 2 additions & 2 deletions testdata/p4_16_errors_outputs/virtual1.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
virtual1.p4(24): [--Werror=type-error] error: return +
virtual1.p4(24): [--Werror=type-error] error: return ix + 1
return (ix + 1);
^^^^^^
---- Actual error:
virtual1.p4(23): Cannot cast implicitly type 'bit<16>' to type 'bool'
bool f(in bit<16> ix) {
^^^^
---- Originating from:
virtual1.p4(24): Source expression '+' produces a result of type 'bit<16>' which cannot be assigned to a left-value with type 'bool'
virtual1.p4(24): Source expression 'ix + 1' produces a result of type 'bit<16>' which cannot be assigned to a left-value with type 'bool'
return (ix + 1);
^^^^^^
virtual1.p4(23)
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_16_errors_outputs/virtual2.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
virtual2.p4(24): [--Werror=type-error] error: return +: return expression in function with void return
virtual2.p4(24): [--Werror=type-error] error: return ix + 1: return expression in function with void return
return (ix + 1);
^^^^^^
virtual2.p4(22): [--Werror=type-error] error: cntr
Expand Down
6 changes: 3 additions & 3 deletions testdata/p4_16_errors_outputs/wrong-cast.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
wrong-cast.p4(1): [--Werror=invalid] error: cast: Only 0 and 1 can be cast to booleans
wrong-cast.p4(1): [--Werror=invalid] error: (bool)3: Only 0 and 1 can be cast to booleans
const bool b = (bool)3;
^^^^^^^
wrong-cast.p4(2): [--Werror=invalid] error: cast: Cannot cast signed value to boolean
wrong-cast.p4(2): [--Werror=invalid] error: (bool)2s0: Cannot cast signed value to boolean
const bool c = (bool)2s0;
^^^^^^^^^
wrong-cast.p4(3): [--Werror=invalid] error: cast: Only bit<1> values can be cast to bool
wrong-cast.p4(3): [--Werror=invalid] error: (bool)10w0: Only bit<1> values can be cast to bool
const bool d = (bool)10w0;
^^^^^^^^^^
2 changes: 1 addition & 1 deletion testdata/p4_16_samples_outputs/array_field.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
array_field.p4(27): [--Wwarn=invalid_header] warning: accessing a field of an invalid header s[a]
s[a].z = 1;
^^^^
array_field.p4(28): [--Wwarn=invalid_header] warning: accessing a field of an invalid header s[+]
array_field.p4(28): [--Wwarn=invalid_header] warning: accessing a field of an invalid header s[a_0/a + 1]
s[a+1].z = 0;
^^^^^^
array_field.p4(29): [--Wwarn=invalid_header] warning: accessing a field of an invalid header s[a]
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_16_samples_outputs/constant_folding.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
constant_folding.p4(95): [--Wwarn=overflow] warning: <<: Shifting 8-bit value with 9
constant_folding.p4(95): [--Wwarn=overflow] warning: 1 << 9: Shifting 8-bit value with 9
z = 8w1 << 9;
^^^^^^^^
constant_folding.p4(95): [--Wwarn=mismatch] warning: 8w512: value does not fit in 8 bits
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
gauntlet_various_ops-bmv2.p4(120): [--Wwarn=overflow] warning: >>: Shifting 4-bit value with 16
gauntlet_various_ops-bmv2.p4(120): [--Wwarn=overflow] warning: 1 >> 16: Shifting 4-bit value with 16
h.rshift.g = 4w1 >> 8w16;
^^^^^^^^^^^
gauntlet_various_ops-bmv2.p4(123): [--Wwarn=mismatch] warning: 4w16: value does not fit in 4 bits
h.lshift.a = (bit<8>)(4w4 << 8w2);
^^^^^^^^^^
gauntlet_various_ops-bmv2.p4(124): [--Wwarn=overflow] warning: <<: Shifting 4-bit value with 16
gauntlet_various_ops-bmv2.p4(124): [--Wwarn=overflow] warning: 4 << 16: Shifting 4-bit value with 16
h.lshift.b = (bit<8>)(4w4 << 8w16);
^^^^^^^^^^^
gauntlet_various_ops-bmv2.p4(124): [--Wwarn=mismatch] warning: 4w262144: value does not fit in 4 bits
h.lshift.b = (bit<8>)(4w4 << 8w16);
^^^^^^^^^^^
gauntlet_various_ops-bmv2.p4(126): [--Wwarn=overflow] warning: <<: Shifting 8-bit value with 256
gauntlet_various_ops-bmv2.p4(126): [--Wwarn=overflow] warning: 1 << 256: Shifting 8-bit value with 256
h.lshift.d = (bit<8>)1 << 256;
^^^^^^^^^^^^^^^^
gauntlet_various_ops-bmv2.p4(126): [--Wwarn=mismatch] warning: 8w115792089237316195423570985008687907853269984665640564039457584007913129639936: value does not fit in 8 bits
Expand Down
4 changes: 2 additions & 2 deletions testdata/p4_16_samples_outputs/issue3289.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
issue3289.p4(3): [--Wwarn=overflow] warning: <<: Shifting 5-bit value with 5
issue3289.p4(3): [--Wwarn=overflow] warning: 1 << 5: Shifting 5-bit value with 5
return (5w1) << 5;
^^^^^^^^^^
issue3289.p4(3): [--Wwarn=mismatch] warning: 5w32: value does not fit in 5 bits
return (5w1) << 5;
^^^^^^^^^^
issue3289.p4(8): [--Wwarn=overflow] warning: <<: Shifting 5-bit value with 6
issue3289.p4(8): [--Wwarn=overflow] warning: 1 << 6: Shifting 5-bit value with 6
return (5w1) << 6;
^^^^^^^^^^
issue3289.p4(8): [--Wwarn=mismatch] warning: 5w64: value does not fit in 5 bits
Expand Down

0 comments on commit e819dc4

Please sign in to comment.