From dddcde56dd9b2c2fa1e1fb97c9a2f76fea4a2b92 Mon Sep 17 00:00:00 2001 From: Jiri Havranek Date: Fri, 8 Sep 2023 18:24:07 +0200 Subject: [PATCH] Fix invalid string format specifier --- ir/ir.cpp | 2 +- testdata/p4_16_errors/issue4144.p4 | 3 +++ testdata/p4_16_errors_outputs/issue4144-first.p4 | 5 +++++ testdata/p4_16_errors_outputs/issue4144-frontend.p4 | 5 +++++ testdata/p4_16_errors_outputs/issue4144.p4 | 5 +++++ testdata/p4_16_errors_outputs/issue4144.p4-stderr | 3 +++ 6 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 testdata/p4_16_errors/issue4144.p4 create mode 100644 testdata/p4_16_errors_outputs/issue4144-first.p4 create mode 100644 testdata/p4_16_errors_outputs/issue4144-frontend.p4 create mode 100644 testdata/p4_16_errors_outputs/issue4144.p4 create mode 100644 testdata/p4_16_errors_outputs/issue4144.p4-stderr diff --git a/ir/ir.cpp b/ir/ir.cpp index b5549bfc69..3fb8176e7a 100644 --- a/ir/ir.cpp +++ b/ir/ir.cpp @@ -278,7 +278,7 @@ const IR::PackageBlock *ToplevelBlock::getMain() const { return nullptr; } if (!main->is()) { - ::error(ErrorType::ERR_INVALID, "%1$: must be a package declaration", main->getNode()); + ::error(ErrorType::ERR_INVALID, "%1%: must be a package declaration", main->getNode()); return nullptr; } auto block = getValue(main->getNode()); diff --git a/testdata/p4_16_errors/issue4144.p4 b/testdata/p4_16_errors/issue4144.p4 new file mode 100644 index 0000000000..a0a8d90209 --- /dev/null +++ b/testdata/p4_16_errors/issue4144.p4 @@ -0,0 +1,3 @@ +#include + +extern main {} diff --git a/testdata/p4_16_errors_outputs/issue4144-first.p4 b/testdata/p4_16_errors_outputs/issue4144-first.p4 new file mode 100644 index 0000000000..4a990eac72 --- /dev/null +++ b/testdata/p4_16_errors_outputs/issue4144-first.p4 @@ -0,0 +1,5 @@ +#include + +extern main { +} + diff --git a/testdata/p4_16_errors_outputs/issue4144-frontend.p4 b/testdata/p4_16_errors_outputs/issue4144-frontend.p4 new file mode 100644 index 0000000000..4a990eac72 --- /dev/null +++ b/testdata/p4_16_errors_outputs/issue4144-frontend.p4 @@ -0,0 +1,5 @@ +#include + +extern main { +} + diff --git a/testdata/p4_16_errors_outputs/issue4144.p4 b/testdata/p4_16_errors_outputs/issue4144.p4 new file mode 100644 index 0000000000..4a990eac72 --- /dev/null +++ b/testdata/p4_16_errors_outputs/issue4144.p4 @@ -0,0 +1,5 @@ +#include + +extern main { +} + diff --git a/testdata/p4_16_errors_outputs/issue4144.p4-stderr b/testdata/p4_16_errors_outputs/issue4144.p4-stderr new file mode 100644 index 0000000000..f1b138d94e --- /dev/null +++ b/testdata/p4_16_errors_outputs/issue4144.p4-stderr @@ -0,0 +1,3 @@ +issue4144.p4(3): [--Werror=invalid] error: main: must be a package declaration +extern main {} + ^^^^