Skip to content

Commit

Permalink
Fix linter complaints in the validateStringAnnotations pass and enabl…
Browse files Browse the repository at this point in the history
…e -werror for MacOS. (#4881)

* Fix linter complaints in the validateStringAnnotations pass.

Signed-off-by: fruffy <[email protected]>

* Enable -werror for MacOS.

Signed-off-by: fruffy <[email protected]>

---------

Signed-off-by: fruffy <[email protected]>
  • Loading branch information
fruffy authored Aug 22, 2024
1 parent 54d4b9d commit 30444b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
run: |
source ~/.bash_profile
./bootstrap.sh -DENABLE_GC=ON -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_UNITY_BUILD=ON -DENABLE_TEST_TOOLS=ON --build-generator "Ninja"
-DCMAKE_UNITY_BUILD=ON -DENABLE_TEST_TOOLS=ON -DENABLE_WERROR=ON --build-generator "Ninja"
cmake --build build -- -j $(nproc)
- name: Run tests (MacOS)
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
run: |
source ~/.bash_profile
./bootstrap.sh -DENABLE_GC=ON -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_UNITY_BUILD=ON -DENABLE_TEST_TOOLS=ON --build-generator "Ninja"
-DCMAKE_UNITY_BUILD=ON -DENABLE_TEST_TOOLS=ON -DENABLE_WERROR=ON --build-generator "Ninja"
cmake --build build -- -j $(nproc)
- name: Run tests (MacOS)
Expand Down
13 changes: 6 additions & 7 deletions frontends/p4/validateStringAnnotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ limitations under the License.

/// @file
/// @brief Check validity of built-in string annotations.

namespace P4 {

/// Checks that the build-in string annotations (\@name, \@deprecated, \@noWarn) have string
/// arguments.
class ValidateStringAnnotations final : public Inspector {
TypeMap *typeMap;

public:
explicit ValidateStringAnnotations() {}
explicit ValidateStringAnnotations() = default;

void postorder(const IR::Annotation *annotation) override {
const auto name = annotation->name;
Expand All @@ -39,13 +36,15 @@ class ValidateStringAnnotations final : public Inspector {
name != IR::Annotation::noWarnAnnotation) {
return;
}
if (annotation->expr.size() != 1)
if (annotation->expr.size() != 1) {
error(ErrorType::ERR_INVALID, "%1%: annotation must have exactly 1 argument",
annotation);
auto e0 = annotation->expr.at(0);
if (!e0->is<IR::StringLiteral>())
}
const auto *e0 = annotation->expr.at(0);
if (!e0->is<IR::StringLiteral>()) {
error(ErrorType::ERR_TYPE_ERROR, "%1%: @%2% annotation's value must be a string", e0,
annotation->name.originalName);
}
}
};

Expand Down

0 comments on commit 30444b0

Please sign in to comment.