From 87d362f409685159470628d565b430abe3342300 Mon Sep 17 00:00:00 2001 From: Jiri Havranek Date: Sat, 9 Sep 2023 01:49:27 +0200 Subject: [PATCH] Fix invalid string format specifier (#4145) --- 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 b5549bfc698..3fb8176e7a4 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 00000000000..a0a8d902094 --- /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 00000000000..4a990eac729 --- /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 00000000000..4a990eac729 --- /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 00000000000..4a990eac729 --- /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 00000000000..f1b138d94ea --- /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 {} + ^^^^