diff --git a/frontends/p4/fromv1.0/converters.cpp b/frontends/p4/fromv1.0/converters.cpp index ed0dbb06f67..def4f61051f 100644 --- a/frontends/p4/fromv1.0/converters.cpp +++ b/frontends/p4/fromv1.0/converters.cpp @@ -221,8 +221,7 @@ const IR::Node *ExpressionConverter::postorder(IR::GlobalRef *ref) { // FIXME -- has put into a different control. In that case, ResolveReferences on this // FIXME -- path will later fail as the declaration is not in scope. We should at // FIXME -- least detect that here and give a warning or other indication of the problem. - return new IR::PathExpression( - ref->srcInfo, new IR::Path(ref->srcInfo, IR::ID(ref->srcInfo, ref->toString()))); + return new IR::PathExpression(ref->srcInfo, new IR::Path(ref->srcInfo, ref->Name())); } /// P4_16 is stricter on comparing booleans with ints diff --git a/frontends/p4/strengthReduction.cpp b/frontends/p4/strengthReduction.cpp index ff66382ef15..f80ff1cdc63 100644 --- a/frontends/p4/strengthReduction.cpp +++ b/frontends/p4/strengthReduction.cpp @@ -413,10 +413,12 @@ const IR::Node *DoStrengthReduction::postorder(IR::Slice *expr) { // out-of-bound error has been caught in type checking if (auto sl = expr->e0->to()) { - auto e = sl->e0; - auto hi = expr->getH() + sl->getL(); - auto lo = expr->getL() + sl->getL(); - return new IR::Slice(e, hi, lo); + int delta = sl->getL(); + expr->e0 = sl->e0; + if (delta != 0) { + expr->e1 = new IR::Constant(expr->getH() + delta); + expr->e2 = new IR::Constant(expr->getL() + delta); + } } auto slice_width = expr->getH() - expr->getL() + 1; diff --git a/ir/base.def b/ir/base.def index 0e7674d52f7..2d1eb635859 100644 --- a/ir/base.def +++ b/ir/base.def @@ -379,7 +379,7 @@ interface IAnnotated { } interface IInstance { - virtual cstring Name() const = 0; + virtual ID Name() const = 0; virtual Type getType() const = 0; } diff --git a/ir/dbprint-p4.cpp b/ir/dbprint-p4.cpp index cd37f714a2c..3e3b265a12e 100644 --- a/ir/dbprint-p4.cpp +++ b/ir/dbprint-p4.cpp @@ -108,7 +108,9 @@ void IR::V1Parser::dbprint(std::ostream &out) const { } void IR::ParserException::dbprint(std::ostream &out) const { out << "IR::ParserException"; } void IR::ParserState::dbprint(std::ostream &out) const { - out << "state " << name << " " << annotations << "{" << indent; + out << "state " << name; + if (dbgetflags(out) & Brief) return; + out << " " << annotations << "{" << indent; for (auto s : components) out << Log::endl << s; if (selectExpression) out << Log::endl << selectExpression; out << " }" << unindent; diff --git a/ir/expression.def b/ir/expression.def index d2130453f8f..7c58a4d6d81 100644 --- a/ir/expression.def +++ b/ir/expression.def @@ -12,6 +12,7 @@ abstract Operation_Unary : Operation { if (!srcInfo && expr) srcInfo = expr->srcInfo; if (type->is() && expr) type = expr->type; } precedence = DBPrint::Prec_Prefix; + toString{ return getStringOp() + expr->toString(); } } class Neg : Operation_Unary { @@ -37,6 +38,11 @@ abstract Operation_Binary : Operation { if (!srcInfo && left && right) srcInfo = left->srcInfo + right->srcInfo; if (type->is() && left && right && left->type == right->type) type = left->type; } + toString { + std::stringstream tmp; + tmp << DBPrint::Prec_Low << *this; + return tmp.str(); + } } abstract Operation_Ternary : Operation { @@ -374,7 +380,7 @@ class Cast : Operation_Unary { /// type, and 'type' will only be updated later when type inferencing occurs precedence = DBPrint::Prec_Prefix; stringOp = "(cast)"; - toString{ return "cast"; } + toString{ return "(" + destType->toString() + ")" + expr->toString(); } validate{ BUG_CHECK(!destType->is(), "%1%: Cannot cast to unknown type", this); } } diff --git a/ir/ir.def b/ir/ir.def index 0a50ad28202..3ea69913038 100644 --- a/ir/ir.def +++ b/ir/ir.def @@ -404,7 +404,7 @@ class Declaration_Instance : Declaration, IAnnotated, IInstance { Annotations getAnnotations() const override { return annotations; } Type getType() const override { return type; } - cstring Name() const override { return name; } + ID Name() const override { return name; } validate{ BUG_CHECK(type->is() || type->is() || type->is(), // P4_14 only? diff --git a/ir/json_generator.h b/ir/json_generator.h index e9a43367fe9..69076009716 100644 --- a/ir/json_generator.h +++ b/ir/json_generator.h @@ -195,29 +195,7 @@ class JSONGenerator { void generate(cstring v) { if (v) { - out << "\""; - for (auto ch : v) { - switch (ch) { - case '\n': - out << "\\n"; - break; - case '\r': - out << "\\r"; - break; - case '\t': - out << "\\t"; - break; - case '\"': - out << "\\\""; - break; - case '\\': - out << "\\\\"; - break; - default: - out << ch; - } - } - out << "\""; + out << "\"" << v.escapeJson() << "\""; } else { out << "null"; } diff --git a/ir/type.def b/ir/type.def index abeedf6a857..b123db18066 100644 --- a/ir/type.def +++ b/ir/type.def @@ -533,6 +533,8 @@ class Type_Specialized : Type { result += ">"; return result; } + Type_Specialized(cstring bt, std::initializer_list args) + : baseType(new Type_Name(bt)), arguments(new Vector(args)) {} } /** Canonical representation of a Type_Specialized; diff --git a/ir/v1.def b/ir/v1.def index f63c6e24bf5..6cf0e028a14 100644 --- a/ir/v1.def +++ b/ir/v1.def @@ -272,7 +272,7 @@ class ParserException {} abstract Attached : IInstance, IAnnotated { optional ID name; optional Annotations annotations = Annotations::empty; - cstring Name() const override { return name; } + ID Name() const override { return name; } virtual const char *kind() const = 0; Type getType() const override { return Type_Unknown::get(); } Annotations getAnnotations() const override { return annotations; } @@ -407,7 +407,7 @@ class V1Table : IInstance, IAnnotated { void addProperty(Property prop) { properties.push_back(prop); } Annotations getAnnotations() const override { return annotations; } toString { return node_type_name() + " " + name; } - cstring Name() const override { return name; } + ID Name() const override { return name; } Type getType() const override { return Type_AnyTable::get(); } } @@ -449,7 +449,8 @@ class GlobalRef : Expression { // FIXME -- interface references directly in the IR GlobalRef { type = obj->to()->getType(); } validate { obj->is(); } - toString { return obj->to()->Name(); } + toString { return obj->to()->toString(); } + ID Name() const { return obj->to()->Name(); } dbprint { out << obj->to()->Name(); } } diff --git a/midend/local_copyprop.h b/midend/local_copyprop.h index f53832ecd56..6a335a518a0 100644 --- a/midend/local_copyprop.h +++ b/midend/local_copyprop.h @@ -150,6 +150,9 @@ class LocalCopyPropagation : public PassManager { passes.push_back(typeChecking); passes.push_back(new DoLocalCopyPropagation(refMap, typeMap, policy, elimUnusedTables)); } + LocalCopyPropagation(ReferenceMap *refMap, TypeMap *typeMap, + std::function policy) + : LocalCopyPropagation(refMap, typeMap, nullptr, policy) {} }; } // namespace P4 diff --git a/testdata/p4_14_errors_outputs/issue905.p4-stderr b/testdata/p4_14_errors_outputs/issue905.p4-stderr index ec6d29a9432..4403f3a3d51 100644 --- a/testdata/p4_14_errors_outputs/issue905.p4-stderr +++ b/testdata/p4_14_errors_outputs/issue905.p4-stderr @@ -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 diff --git a/testdata/p4_16_errors_outputs/binary_e.p4-stderr b/testdata/p4_16_errors_outputs/binary_e.p4-stderr index 228dfd38c9d..6c521a17ad0 100644 --- a/testdata/p4_16_errors_outputs/binary_e.p4-stderr +++ b/testdata/p4_16_errors_outputs/binary_e.p4-stderr @@ -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 ^^^^^ diff --git a/testdata/p4_16_errors_outputs/const1_e.p4-stderr b/testdata/p4_16_errors_outputs/const1_e.p4-stderr index 3b115bab9cc..32c4bc8613e 100644 --- a/testdata/p4_16_errors_outputs/const1_e.p4-stderr +++ b/testdata/p4_16_errors_outputs/const1_e.p4-stderr @@ -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; ^^^^^ diff --git a/testdata/p4_16_errors_outputs/div.p4-stderr b/testdata/p4_16_errors_outputs/div.p4-stderr index 33f75e4551e..a413c2b02d1 100644 --- a/testdata/p4_16_errors_outputs/div.p4-stderr +++ b/testdata/p4_16_errors_outputs/div.p4-stderr @@ -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; ^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/div0.p4-stderr b/testdata/p4_16_errors_outputs/div0.p4-stderr index 5ad4493fba5..4f7890097eb 100644 --- a/testdata/p4_16_errors_outputs/div0.p4-stderr +++ b/testdata/p4_16_errors_outputs/div0.p4-stderr @@ -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; ^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/div1.p4-stderr b/testdata/p4_16_errors_outputs/div1.p4-stderr index 7743d70407b..6e9af70866f 100644 --- a/testdata/p4_16_errors_outputs/div1.p4-stderr +++ b/testdata/p4_16_errors_outputs/div1.p4-stderr @@ -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; ^^^^^^ diff --git a/testdata/p4_16_errors_outputs/div3.p4-stderr b/testdata/p4_16_errors_outputs/div3.p4-stderr index 8db6f2540b6..32e38aa13ae 100644 --- a/testdata/p4_16_errors_outputs/div3.p4-stderr +++ b/testdata/p4_16_errors_outputs/div3.p4-stderr @@ -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 ^^^^^ diff --git a/testdata/p4_16_errors_outputs/issue1542.p4-stderr b/testdata/p4_16_errors_outputs/issue1542.p4-stderr index 906df8d4090..f807dc17848 100644 --- a/testdata/p4_16_errors_outputs/issue1542.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue1542.p4-stderr @@ -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) diff --git a/testdata/p4_16_errors_outputs/issue2206.p4-stderr b/testdata/p4_16_errors_outputs/issue2206.p4-stderr index 7ddc68f2cb7..c7e0471a316 100644 --- a/testdata/p4_16_errors_outputs/issue2206.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue2206.p4-stderr @@ -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; ^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/issue2444-1.p4-stderr b/testdata/p4_16_errors_outputs/issue2444-1.p4-stderr index 89fcc743351..c13b265b899 100644 --- a/testdata/p4_16_errors_outputs/issue2444-1.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue2444-1.p4-stderr @@ -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; ^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/issue2496.p4-stderr b/testdata/p4_16_errors_outputs/issue2496.p4-stderr index ffdfc31bd39..2f5c4ae6164 100644 --- a/testdata/p4_16_errors_outputs/issue2496.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue2496.p4-stderr @@ -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; ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/issue3057-1.p4-stderr b/testdata/p4_16_errors_outputs/issue3057-1.p4-stderr index c5fad282bb2..027d2cd5dc0 100644 --- a/testdata/p4_16_errors_outputs/issue3057-1.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue3057-1.p4-stderr @@ -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}; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/issue3221.p4-stderr b/testdata/p4_16_errors_outputs/issue3221.p4-stderr index f1311d4dc4d..3b2ad653981 100644 --- a/testdata/p4_16_errors_outputs/issue3221.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue3221.p4-stderr @@ -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: diff --git a/testdata/p4_16_errors_outputs/issue401.p4-stderr b/testdata/p4_16_errors_outputs/issue401.p4-stderr index 6e7f8baab07..10774810d19 100644 --- a/testdata/p4_16_errors_outputs/issue401.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue401.p4-stderr @@ -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: diff --git a/testdata/p4_16_errors_outputs/issue473.p4-stderr b/testdata/p4_16_errors_outputs/issue473.p4-stderr index cb045237f30..1e13865efa9 100644 --- a/testdata/p4_16_errors_outputs/issue473.p4-stderr +++ b/testdata/p4_16_errors_outputs/issue473.p4-stderr @@ -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); ^^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/key-name.p4-stderr b/testdata/p4_16_errors_outputs/key-name.p4-stderr index 4fef296cc1f..b7bb16d6e0d 100644 --- a/testdata/p4_16_errors_outputs/key-name.p4-stderr +++ b/testdata/p4_16_errors_outputs/key-name.p4-stderr @@ -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; } ^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/neg.p4-stderr b/testdata/p4_16_errors_outputs/neg.p4-stderr index 7822933663f..8db09b8531c 100644 --- a/testdata/p4_16_errors_outputs/neg.p4-stderr +++ b/testdata/p4_16_errors_outputs/neg.p4-stderr @@ -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; ^^^^^ diff --git a/testdata/p4_16_errors_outputs/newtype-err.p4-stderr b/testdata/p4_16_errors_outputs/newtype-err.p4-stderr index 570d236840e..3130e54af98 100644 --- a/testdata/p4_16_errors_outputs/newtype-err.p4-stderr +++ b/testdata/p4_16_errors_outputs/newtype-err.p4-stderr @@ -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) diff --git a/testdata/p4_16_errors_outputs/psa-meter2.p4-stderr b/testdata/p4_16_errors_outputs/psa-meter2.p4-stderr index 985fa64ce81..a970493ad99 100644 --- a/testdata/p4_16_errors_outputs/psa-meter2.p4-stderr +++ b/testdata/p4_16_errors_outputs/psa-meter2.p4-stderr @@ -1,4 +1,4 @@ -psa-meter2.p4(57): [--Werror=type-error] error: cast +psa-meter2.p4(57): [--Werror=type-error] error: (bit<16>)meter0.execute b.data = (bit<16>)meter0.execute(index, PSA_MeterColor_t.GREEN); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- Actual error: diff --git a/testdata/p4_16_errors_outputs/range_e.p4-stderr b/testdata/p4_16_errors_outputs/range_e.p4-stderr index d55c64d3313..987144b038e 100644 --- a/testdata/p4_16_errors_outputs/range_e.p4-stderr +++ b/testdata/p4_16_errors_outputs/range_e.p4-stderr @@ -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 ^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/serenum-type.p4-stderr b/testdata/p4_16_errors_outputs/serenum-type.p4-stderr index 8192d0b9913..fc77d871ad7 100644 --- a/testdata/p4_16_errors_outputs/serenum-type.p4-stderr +++ b/testdata/p4_16_errors_outputs/serenum-type.p4-stderr @@ -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: diff --git a/testdata/p4_16_errors_outputs/serenum-typedef.p4-stderr b/testdata/p4_16_errors_outputs/serenum-typedef.p4-stderr index 95b56d924d7..769fcd9b6e2 100644 --- a/testdata/p4_16_errors_outputs/serenum-typedef.p4-stderr +++ b/testdata/p4_16_errors_outputs/serenum-typedef.p4-stderr @@ -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: diff --git a/testdata/p4_16_errors_outputs/signs.p4-stderr b/testdata/p4_16_errors_outputs/signs.p4-stderr index 60463dd13b5..b0ef2871250 100644 --- a/testdata/p4_16_errors_outputs/signs.p4-stderr +++ b/testdata/p4_16_errors_outputs/signs.p4-stderr @@ -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; ^^^^^ diff --git a/testdata/p4_16_errors_outputs/table-entries-lpm-2.p4-stderr b/testdata/p4_16_errors_outputs/table-entries-lpm-2.p4-stderr index eaf69f2c16a..df59a585545 100644 --- a/testdata/p4_16_errors_outputs/table-entries-lpm-2.p4-stderr +++ b/testdata/p4_16_errors_outputs/table-entries-lpm-2.p4-stderr @@ -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); ^^^^^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/table-entries-optional-2-bmv2.p4-stderr b/testdata/p4_16_errors_outputs/table-entries-optional-2-bmv2.p4-stderr index 0f42c23a1bc..ef394c76640 100644 --- a/testdata/p4_16_errors_outputs/table-entries-optional-2-bmv2.p4-stderr +++ b/testdata/p4_16_errors_outputs/table-entries-optional-2-bmv2.p4-stderr @@ -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); ^^^^^^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/tuple-newtype.p4-stderr b/testdata/p4_16_errors_outputs/tuple-newtype.p4-stderr index d03c9f97040..1660e362c27 100644 --- a/testdata/p4_16_errors_outputs/tuple-newtype.p4-stderr +++ b/testdata/p4_16_errors_outputs/tuple-newtype.p4-stderr @@ -1,6 +1,6 @@ tuple-newtype.p4(5): [--Werror=type-error] error: T: `type' can only be applied to base types type tuple T; ^ -tuple-newtype.p4(12): [--Werror=type-error] error: cast: Illegal cast from tuple> to T +tuple-newtype.p4(12): [--Werror=type-error] error: (T)ListExpression: Illegal cast from tuple> to T T tt2 = (T){1w0}; ^^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/virtual1.p4-stderr b/testdata/p4_16_errors_outputs/virtual1.p4-stderr index f4151e3dae6..2d4cac44a81 100644 --- a/testdata/p4_16_errors_outputs/virtual1.p4-stderr +++ b/testdata/p4_16_errors_outputs/virtual1.p4-stderr @@ -1,4 +1,4 @@ -virtual1.p4(24): [--Werror=type-error] error: return + +virtual1.p4(24): [--Werror=type-error] error: return ix + 1 return (ix + 1); ^^^^^^ ---- Actual error: @@ -6,7 +6,7 @@ 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) diff --git a/testdata/p4_16_errors_outputs/virtual2.p4-stderr b/testdata/p4_16_errors_outputs/virtual2.p4-stderr index fce2e0b90be..ec4bd8f67a2 100644 --- a/testdata/p4_16_errors_outputs/virtual2.p4-stderr +++ b/testdata/p4_16_errors_outputs/virtual2.p4-stderr @@ -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 diff --git a/testdata/p4_16_errors_outputs/wrong-cast.p4-stderr b/testdata/p4_16_errors_outputs/wrong-cast.p4-stderr index c0738c4b9b5..34c5659590d 100644 --- a/testdata/p4_16_errors_outputs/wrong-cast.p4-stderr +++ b/testdata/p4_16_errors_outputs/wrong-cast.p4-stderr @@ -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; ^^^^^^^^^^ diff --git a/testdata/p4_16_samples_outputs/array_field.p4-stderr b/testdata/p4_16_samples_outputs/array_field.p4-stderr index be3218351bb..f16e6ed9522 100644 --- a/testdata/p4_16_samples_outputs/array_field.p4-stderr +++ b/testdata/p4_16_samples_outputs/array_field.p4-stderr @@ -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] diff --git a/testdata/p4_16_samples_outputs/constant_folding.p4-stderr b/testdata/p4_16_samples_outputs/constant_folding.p4-stderr index 385d0835e9b..f20e2e3ea0d 100644 --- a/testdata/p4_16_samples_outputs/constant_folding.p4-stderr +++ b/testdata/p4_16_samples_outputs/constant_folding.p4-stderr @@ -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 diff --git a/testdata/p4_16_samples_outputs/gauntlet_various_ops-bmv2.p4-stderr b/testdata/p4_16_samples_outputs/gauntlet_various_ops-bmv2.p4-stderr index 18dca659fad..1899bc36665 100644 --- a/testdata/p4_16_samples_outputs/gauntlet_various_ops-bmv2.p4-stderr +++ b/testdata/p4_16_samples_outputs/gauntlet_various_ops-bmv2.p4-stderr @@ -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 diff --git a/testdata/p4_16_samples_outputs/issue3289.p4-stderr b/testdata/p4_16_samples_outputs/issue3289.p4-stderr index 6dde2821ad2..728666cea48 100644 --- a/testdata/p4_16_samples_outputs/issue3289.p4-stderr +++ b/testdata/p4_16_samples_outputs/issue3289.p4-stderr @@ -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