blob: 2fd79cf9d86f49a5322f992e7c0f6a3e103fc039 [file] [log] [blame]
Wyatt Hepler38b6d442021-04-09 15:32:34 -07001// Copyright 2021 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14
15#include "pw_preprocessor/compiler.h"
16
17#include <cstdint>
18
19#include "gtest/gtest.h"
20
21namespace pw::preprocessor {
22namespace {
23
24PW_MODIFY_DIAGNOSTICS_PUSH();
25PW_MODIFY_DIAGNOSTIC(ignored, "-Wunused-variable");
26
27int this_variable_is_unused;
28
29PW_MODIFY_DIAGNOSTICS_POP();
30
31class Foo {
32 PW_MODIFY_DIAGNOSTICS_PUSH();
33 PW_MODIFY_DIAGNOSTIC(ignored, "-Wunused");
34
35 int this_field_is_unused;
36
37 PW_MODIFY_DIAGNOSTICS_POP();
38};
39
40TEST(CompilerMacros, ModifyDiagnostics) {
41 PW_MODIFY_DIAGNOSTICS_PUSH();
42 PW_MODIFY_DIAGNOSTIC(ignored, "-Wunused-variable");
43
44 int this_variable_also_is_unused;
45
46 PW_MODIFY_DIAGNOSTICS_POP();
47}
48
49} // namespace
50} // namespace pw::preprocessor