diff --git a/docs/features.md b/docs/features.md index e7822c2..486880e 100644 --- a/docs/features.md +++ b/docs/features.md @@ -88,12 +88,11 @@ the relevant build mode is active. All are enabled by default except where noted requires static system archives (unavailable on some toolchains, e.g. AutoSD). ## Warnings -Opt-in / disabled by default unless noted otherwise. -- **`minimal_warnings`** (both) — Baseline warning set (includes `-Wall`). - Enabled by default on QNX; opt-in (disabled by default) on Linux. -- **`strict_warnings`** (both) — Stricter warnings; implies `minimal_warnings`. -- **`all_wall_warnings`** (Linux) — Broadest warning set; implies `strict_warnings`. -- **`warnings_as_errors`** (both) — Adds `-Werror`. +**Note:** Warning-level features (`minimal_warnings`, `strict_warnings`, `all_wall_warnings`, `warnings_as_errors`) +have been migrated to [`score_cpp_policies`](https://github.com/eclipse-score/score_cpp_policies). + +These features are no longer defined by this toolchain but can be provided through *feature injection* via +the `extra_known_features` / `extra_enabled_features` attributes on `gcc.toolchain(...)`. ## Sanitizers (Linux, opt-in) Sanitizers are **not** defined by this toolchain. They are provided as diff --git a/docs/test_suite.md b/docs/test_suite.md index 49bcb57..14f91d0 100644 --- a/docs/test_suite.md +++ b/docs/test_suite.md @@ -43,59 +43,48 @@ These tests verify that specific toolchain features are correctly implemented an - Tests `-iquote` quote search paths - Verifies `-isystem` system include paths -3. **`warnings_test`** - Warning level configuration - - Tests strict_warnings, minimal_warnings, warnings_as_errors features - - Includes code patterns that trigger specific warnings - -4. **`warning_override_test`** - Warning feature override via user flags - - Regression test verifying user flags (copts) can override enabled warning features - - Enables both `strict_warnings` and `warnings_as_errors` features (making warnings into errors) - - Provides conflicting `-Wno-shadow` via copts to override the warning - - Validates that the flag ordering is correct: user_compile_flags comes after warning features, - ensuring user flags take precedence. If ordering regresses, compilation will fail with an error. - -5. **`coverage_test`** - Code coverage instrumentation +3. **`coverage_test`** - Code coverage instrumentation - Verifies code coverage instrumentation flags are applied - Provides multiple code paths for coverage analysis - Can be analyzed with: `bazel coverage --combined_report=lcov //feature_verification:coverage_test` -6. **`pic_test`** - Position-Independent Code (`-fPIC`) +4. **`pic_test`** - Position-Independent Code (`-fPIC`) - Tests -fPIC flag is correctly applied - Validates position-independent code patterns - Tests polymorphism, static variables, and C linkage with PIC -7. **`pthread_test`** - POSIX threading support +5. **`pthread_test`** - POSIX threading support - Verifies `-lpthread` correctly links pthread library - Tests thread creation, synchronization, and joining - Validates multiple threads can safely access shared state -8. **`multifile_test`** - Multi-file compilation and archiving +6. **`multifile_test`** - Multi-file compilation and archiving - Tests multiple source files compile into separate object files - Validates object files are combined by archiver into static libraries - Complex operations across multiple object files link correctly -9. **`whole_archive_test`** - Whole-archive linking (`-Wl,--whole-archive`) +7. **`whole_archive_test`** - Whole-archive linking (`-Wl,--whole-archive`) - Verifies `-Wl,--whole-archive` and `-Wl,--no-whole-archive` work - Tests unused library symbols are linked when using whole-archive -10. **`preprocessor_defines_test`** - `preprocessor_defines` feature +8. **`preprocessor_defines_test`** - `preprocessor_defines` feature - Injects defines via the `local_defines` attribute (routed through the `preprocessor_defines` feature), unlike `defines_test` which uses `copts` (routed through `user_compile_flags`) -11. **`include_dir_test`** - `include_paths` via the `includes` attribute +9. **`include_dir_test`** - `include_paths` via the `includes` attribute - Includes a header exposed through a library's `includes` attribute, exercising the `-I`/`-isystem` search paths -12. **`user_link_flags_test`** - `user_link_flags` feature +10. **`user_link_flags_test`** - `user_link_flags` feature - Passes a linker flag through `linkopts` (`-Wl,--defsym=...`) and checks the injected symbol's address at runtime -13. **`random_seed_test`** - `random_seed` feature +11. **`random_seed_test`** - `random_seed` feature - Build-and-run smoke test exercising internal-linkage symbols governed by the reproducible-build random seed -14. **`fully_static_link_test`** - `fully_static_link` feature (`-static`) +12. **`fully_static_link_test`** - `fully_static_link` feature (`-static`) - Verifies no shared objects are mapped at runtime (fully static binary) - Marked incompatible with toolchains lacking static system archives (AutoSD) @@ -286,16 +275,16 @@ when the host equals the target). ### All tests on the host (`//...`) ``` -Executed 20 tests: 20 passed +Executed 18 tests: 18 passed ``` ### Feature Verification Tests -- The `feature_verification_tests` suite aggregates 13 tests. `warnings_test` - is defined separately and is picked up by wildcard targets such as - `//feature_verification/...`. +- The `feature_verification_tests` suite aggregates 12 tests. + **Note:** Warning-level tests (`warnings_test`, `warning_override_test`) have been migrated to + [`score_cpp_policies`](https://github.com/eclipse-score/score_cpp_policies). - Expected output for the suite: ``` - Executed 13 tests: 13 passed + Executed 12 tests: 12 passed ``` ### Language and Standards Tests @@ -324,8 +313,6 @@ tests/ │ ├── user_link_flags_test.cpp │ ├── random_seed_test.cpp │ ├── fully_static_link_test.cpp -│ ├── warnings_test.cpp -│ ├── warning_override_test.cpp │ ├── coverage_test.cpp │ ├── pic_test_lib.h/cpp, pic_test.cpp │ ├── multifile_lib.h and multifile_lib_*.cpp diff --git a/templates/linux/cc_toolchain_config.bzl.template b/templates/linux/cc_toolchain_config.bzl.template index 1675dee..c5480ff 100644 --- a/templates/linux/cc_toolchain_config.bzl.template +++ b/templates/linux/cc_toolchain_config.bzl.template @@ -39,16 +39,6 @@ load(":flags.bzl", "DEFAULT_LINK_FLAGS", "DBG_COMPILE_FLAGS", "OPT_COMPILE_FLAGS", - "MINIMAL_WARNINGS_FLAGS", - "MINIMAL_C_WARNINGS_FLAGS", - "MINIMAL_CXX_WARNINGS_FLAGS", - "STRICT_WARNINGS_FLAGS", - "STRICT_C_WARNINGS_FLAGS", - "STRICT_CXX_WARNINGS_FLAGS", - "ALL_WALL_WARNINGS", - "ALL_WALL_C_WARNINGS", - "ALL_WALL_CXX_WARNINGS", - "WARNINGS_AS_ERRORS", ) all_cpp_compile_actions = [ @@ -292,76 +282,6 @@ def _impl(ctx): ], ) - minimal_warnings_feature = feature( - name = "minimal_warnings", - enabled = False, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = MINIMAL_WARNINGS_FLAGS, - ), - flag_set( - actions = all_c_compile_actions, - flag_groups = MINIMAL_C_WARNINGS_FLAGS, - ), - flag_set( - actions = all_cpp_compile_actions, - flag_groups = MINIMAL_CXX_WARNINGS_FLAGS, - ), - ], - ) - - strict_warnings_feature = feature( - name = "strict_warnings", - implies = ["minimal_warnings"], - enabled = False, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = STRICT_WARNINGS_FLAGS, - ), - flag_set( - actions = all_cpp_compile_actions, - flag_groups = STRICT_CXX_WARNINGS_FLAGS, - ), - flag_set( - actions = all_c_compile_actions, - flag_groups = STRICT_C_WARNINGS_FLAGS, - ), - ], - ) - - all_wall_warnings_feature = feature( - name = "all_wall_warnings", - implies = ["strict_warnings"], - enabled = False, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = ALL_WALL_WARNINGS, - ), - flag_set( - actions = all_c_compile_actions, - flag_groups = ALL_WALL_C_WARNINGS, - ), - flag_set( - actions = all_cpp_compile_actions, - flag_groups = ALL_WALL_CXX_WARNINGS, - ), - ], - ) - - warnings_as_errors_feature = feature( - name = "warnings_as_errors", - enabled = False, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = WARNINGS_AS_ERRORS, - ), - ], - ) - extra_compile_flags = %{extra_compile_flags} extra_compile_flags_feature = feature( name = "extra_compile_flags", @@ -1024,10 +944,9 @@ def _impl(ctx): random_seed_feature, include_paths_feature, preprocessor_defines_feature, - minimal_warnings_feature, - strict_warnings_feature, - all_wall_warnings_feature, - warnings_as_errors_feature, + extra_compile_flags_feature, + extra_c_compile_flags_feature, + extra_cxx_compile_flags_feature, user_compile_flags_feature, compiler_input_flags_feature, compiler_output_flags_feature, @@ -1051,9 +970,6 @@ def _impl(ctx): fully_static_link_feature, sysroot_link_flags_feature, pthread_feature, - extra_compile_flags_feature, - extra_c_compile_flags_feature, - extra_cxx_compile_flags_feature, extra_link_flags_feature, opt_feature, supports_dynamic_linker_feature, diff --git a/templates/linux/cc_toolchain_flags.bzl.template b/templates/linux/cc_toolchain_flags.bzl.template index b42f862..416275e 100644 --- a/templates/linux/cc_toolchain_flags.bzl.template +++ b/templates/linux/cc_toolchain_flags.bzl.template @@ -93,163 +93,3 @@ DEFAULT_LINK_FLAGS = get_flag_group([ "-static-libgcc", ]) -# Minimal set of warning flags to enable useful warnings without overwhelming the user. -# ----------------------------------------------------------------------------- -# MINIMAL: The Base Group -# ----------------------------------------------------------------------------- -MINIMAL_WARNINGS_FLAGS = get_flag_group([ - "-Wall", - "-Wcast-align", - "-Wcast-qual", - "-Wformat-nonliteral", - "-Wformat-signedness", - "-Wformat=2", - "-Wmissing-format-attribute", - "-Wpointer-arith", - "-Wredundant-decls", - "-Wreturn-local-addr", - "-Wsizeof-array-argument", - "-Wundef", - "-Wwrite-strings", -]) - -MINIMAL_C_WARNINGS_FLAGS = get_flag_group([ - "-Wbad-function-cast", - "-Wmissing-prototypes", -]) - -MINIMAL_CXX_WARNINGS_FLAGS = get_flag_group([ - "-Wodr", - "-Wreorder", -]) - -# ----------------------------------------------------------------------------- -# STRICT: Extends MINIMAL -# (Excludes flags already defined in MINIMAL) -# ----------------------------------------------------------------------------- -STRICT_WARNINGS_FLAGS = get_flag_group([ - "-Wbool-compare", - "-Wconversion", - "-Wdouble-promotion", - "-Wextra", - "-Winvalid-pch", - "-Wlogical-not-parentheses", - "-Wlogical-op", - "-Wpedantic", - "-Wswitch-bool", - "-Wunused-but-set-parameter", - "-Wvla", -]) - -STRICT_C_WARNINGS_FLAGS = get_flag_group([ - # No additional strict C warnings for now -]) - -STRICT_CXX_WARNINGS_FLAGS = get_flag_group([ - "-Wnarrowing", -]) - -# ----------------------------------------------------------------------------- -# ALL: Extends STRICT -# (Excludes flags already defined in MINIMAL or STRICT) -# ----------------------------------------------------------------------------- -ALL_WALL_C_WARNINGS = get_flag_group([ - "-Wimplicit", - "-Wimplicit-function-declaration", - "-Wimplicit-int", - "-Wpointer-sign", - "-Wvla-parameter", -]) - -ALL_WALL_CXX_WARNINGS = get_flag_group([ - "-Waligned-new", - "-Wc++11-compat", - "-Wc++14-compat", - "-Wc++17-compat", - "-Wc++20-compat", - "-Wcatch-value", - "-Wclass-memaccess", - "-Wdelete-non-virtual-dtor", - # "-Wenum-int-mismatch", not supported in GCC12.2 - # "-Wargument-mismatch", cc1plus: warning: command-line option '-Wduplicate-decl-specifier' is valid for C/ObjC but not for C++ - "-Wmismatched-new-delete", - "-Woverloaded-virtual", - # -Woverloaded-virtual=1, not supported in GCC12.2 - "-Wpessimizing-move", - "-Wrange-loop-construct", - # "-Wself-move", not supported in GCC12.2 - "-Wuseless-cast", -]) - -ALL_WALL_WARNINGS = get_flag_group([ - "-Waddress", - "-Warray-bounds=1", - "-Warray-compare", - "-Warray-parameter=2", - "-Wbool-operation", - "-Wchar-subscripts", - "-Wcomment", - "-Wdangling-else", - "-Wdangling-pointer=2", - "-Wduplicate-decl-specifier", - "-Wenum-compare", - "-Wformat-contains-nul", - "-Wformat-diag", - "-Wformat-extra-args", - "-Wformat-overflow=1", - "-Wformat-truncation=1", - "-Wformat-zero-length", - "-Wformat=1", - "-Wframe-address", - "-Winfinite-recursion", - "-Winit-self", - "-Wint-in-bool-context", - "-Wmain", - "-Wmaybe-uninitialized", - "-Wmemset-elt-size", - "-Wmemset-transposed-args", - "-Wmisleading-indentation", - "-Wmismatched-dealloc", - "-Wmissing-attributes", - "-Wmissing-braces", - "-Wmultistatement-macros", - "-Wnonnull", - "-Wnonnull-compare", - "-Wopenmp-simd", - "-Wpacked-not-aligned", - "-Wparentheses", - "-Wrestrict", - "-Wreturn-type", - "-Wsequence-point", - "-Wsign-compare", - "-Wsizeof-array-div", - "-Wsizeof-pointer-div", - "-Wsizeof-pointer-memaccess", - "-Wstrict-aliasing", - "-Wstrict-overflow=1", - "-Wswitch", - "-Wtautological-compare", - "-Wtrigraphs", - "-Wuninitialized", - "-Wunknown-pragmas", - "-Wunused", - "-Wunused-but-set-variable", - "-Wunused-const-variable=1", - "-Wunused-function", - "-Wunused-label", - "-Wunused-local-typedefs", - "-Wunused-value", - "-Wunused-variable", - "-Wuse-after-free=2", - "-Wvolatile-register-var", - "-Wzero-length-bounds", -]) - -# ----------------------------------------------------------------------------- -# : Turn all warinings into errors -# ----------------------------------------------------------------------------- -WARNINGS_AS_ERRORS = get_flag_group([ - "-Werror", - "-Wno-error=deprecated-declarations", -]) - diff --git a/templates/qnx/cc_toolchain_config.bzl.template b/templates/qnx/cc_toolchain_config.bzl.template index 4f0059c..cfd7742 100644 --- a/templates/qnx/cc_toolchain_config.bzl.template +++ b/templates/qnx/cc_toolchain_config.bzl.template @@ -37,16 +37,6 @@ load(":flags.bzl", "DEFAULT_LINK_FLAGS", "DBG_COMPILE_FLAGS", "OPT_COMPILE_FLAGS", - "MINIMAL_WARNINGS_FLAGS", - "MINIMAL_C_WARNINGS_FLAGS", - "MINIMAL_CXX_WARNINGS_FLAGS", - "STRICT_WARNINGS_FLAGS", - "STRICT_C_WARNINGS_FLAGS", - "STRICT_CXX_WARNINGS_FLAGS", - "ALL_WALL_WARNINGS", - "ALL_WALL_C_WARNINGS", - "ALL_WALL_CXX_WARNINGS", - "WARNINGS_AS_ERRORS", ) all_cpp_compile_actions = [ @@ -549,76 +539,6 @@ def _impl(ctx): ], ) - minimal_warnings_feature = feature( - name = "minimal_warnings", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = MINIMAL_WARNINGS_FLAGS, - ), - flag_set( - actions = all_c_compile_actions, - flag_groups = MINIMAL_C_WARNINGS_FLAGS, - ), - flag_set( - actions = all_cpp_compile_actions, - flag_groups = MINIMAL_CXX_WARNINGS_FLAGS, - ), - ], - ) - - strict_warnings_feature = feature( - name = "strict_warnings", - implies = ["minimal_warnings"], - enabled = False, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = STRICT_WARNINGS_FLAGS, - ), - flag_set( - actions = all_cpp_compile_actions, - flag_groups = STRICT_CXX_WARNINGS_FLAGS, - ), - flag_set( - actions = all_c_compile_actions, - flag_groups = STRICT_C_WARNINGS_FLAGS, - ), - ], - ) - - all_wall_warnings_feature = feature( - name = "all_wall_warnings", - implies = ["strict_warnings"], - enabled = False, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = ALL_WALL_WARNINGS, - ), - flag_set( - actions = all_c_compile_actions, - flag_groups = ALL_WALL_C_WARNINGS, - ), - flag_set( - actions = all_cpp_compile_actions, - flag_groups = ALL_WALL_CXX_WARNINGS, - ), - ], - ) - - warnings_as_errors_feature = feature( - name = "warnings_as_errors", - enabled = False, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = WARNINGS_AS_ERRORS, - ), - ], - ) - extra_compile_flags = %{extra_compile_flags} extra_compile_flags_feature = feature( name = "extra_compile_flags", @@ -808,10 +728,7 @@ def _impl(ctx): random_seed_feature, include_paths_feature, preprocessor_defines_feature, - minimal_warnings_feature, - strict_warnings_feature, - all_wall_warnings_feature, - warnings_as_errors_feature, + extra_compile_flags_feature, user_compile_flags_feature, compiler_input_flags_feature, compiler_output_flags_feature, @@ -826,7 +743,6 @@ def _impl(ctx): output_execpath_flags_feature, libraries_to_link_feature, coverage_feature, - extra_compile_flags_feature, extra_link_flags_feature, opt_feature, use_license_env_info_feautre, diff --git a/templates/qnx/cc_toolchain_flags.bzl.template b/templates/qnx/cc_toolchain_flags.bzl.template index ba18bc6..52c2bf3 100644 --- a/templates/qnx/cc_toolchain_flags.bzl.template +++ b/templates/qnx/cc_toolchain_flags.bzl.template @@ -79,41 +79,3 @@ DEFAULT_LINK_FLAGS = get_flag_group([ "-lm", "-Wl,--pop-state", ]) - -# Minimal set of warning flags to enable useful warnings without overwhelming the user. -# ----------------------------------------------------------------------------- -# MINIMAL: The Base Group -# ----------------------------------------------------------------------------- -MINIMAL_WARNINGS_FLAGS = get_flag_group([ - "-Wall", - "-Wno-error=deprecated-declarations", - "-Wno-error=mismatched-new-delete", # See what we will do with this (only on GCC12.2.0 supported!) -]) -MINIMAL_C_WARNINGS_FLAGS = get_flag_group([]) -MINIMAL_CXX_WARNINGS_FLAGS = get_flag_group([]) - -# ----------------------------------------------------------------------------- -# STRICT: Extends MINIMAL -# (Excludes flags already defined in MINIMAL) -# ----------------------------------------------------------------------------- -STRICT_WARNINGS_FLAGS = get_flag_group([ - "-Wextra", - "-Wpedantic", -]) -STRICT_C_WARNINGS_FLAGS = get_flag_group([]) -STRICT_CXX_WARNINGS_FLAGS = get_flag_group([]) - -# ----------------------------------------------------------------------------- -# ALL: Extends STRICT -# (Excludes flags already defined in MINIMAL or STRICT) -# ----------------------------------------------------------------------------- -ALL_WALL_C_WARNINGS = get_flag_group([]) -ALL_WALL_CXX_WARNINGS = get_flag_group([]) -ALL_WALL_WARNINGS = get_flag_group([]) - -# ----------------------------------------------------------------------------- -# : Turn all warinings into errors -# ----------------------------------------------------------------------------- -WARNINGS_AS_ERRORS = get_flag_group([ - "-Werror", -]) diff --git a/tests/BUILD b/tests/BUILD index b56ae88..501e233 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -49,7 +49,6 @@ test_suite( "//feature_verification:pthread_test", "//feature_verification:random_seed_test", "//feature_verification:user_link_flags_test", - "//feature_verification:warning_override_test", "//feature_verification:whole_archive_test", ], ) diff --git a/tests/feature_verification/BUILD b/tests/feature_verification/BUILD index 78b012d..e971ff3 100644 --- a/tests/feature_verification/BUILD +++ b/tests/feature_verification/BUILD @@ -136,34 +136,6 @@ cc_test( srcs = ["random_seed_test.cpp"], ) -# Test for: strict_warnings, minimal_warnings, warnings_as_errors features -# Verifies that warning levels are correctly configured -cc_test( - name = "warnings_test", - srcs = ["warnings_test.cpp"], -) - -# Test for: warning feature override via user_compile_flags -# Verifies that user-provided flags (via copts) can override enabled warning -# features. This regression test ensures that the flag ordering between warning -# features and user_compile_flags is correct: user_compile_flags must come -# after warning features so that user flags take precedence. -# -# The test enables both strict_warnings and warnings_as_errors (making warnings -# into errors), then provides -Wno-shadow via copts. If the flag ordering is -# correct, the test compiles successfully because user's -Wno-shadow overrides -# the -Wshadow error. If ordering regresses, compilation will fail with a -# -Wshadow error, immediately catching the regression. -cc_test( - name = "warning_override_test", - srcs = ["warning_override_test.cpp"], - copts = ["-Wno-shadow"], - features = [ - "strict_warnings", - "warnings_as_errors", - ], -) - # Test for: coverage, gcc_coverage_map_format, dependency_file features # Verifies that code coverage instrumentation is applied. Also used by both # Linux and QNX CI as the `bazel coverage` smoke test (build/link/execute/gcov diff --git a/tests/feature_verification/warning_override_test.cpp b/tests/feature_verification/warning_override_test.cpp deleted file mode 100644 index 59bab08..0000000 --- a/tests/feature_verification/warning_override_test.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2026 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -// Test for: warning feature override via user flags (copts) -// -// This test verifies that the ordering between warning features and user flags -// is correct. Specifically, it tests that: -// -// 1. strict_warnings (implies minimal_warnings which enables -Wall) and -// warnings_as_errors are both enabled, making -Wshadow an error -// 2. Code with variable shadowing would trigger an error -// 3. User provides -Wno-shadow via copts (which becomes user_compile_flags) -// 4. The compilation SUCCEEDS because user_compile_flags comes AFTER warning -// features in the features list, making user flags take precedence -// -// If the flag ordering regresses (e.g., warning features come after user flags), -// this test will fail to compile with a -Wshadow error, catching the regression -// immediately. - -#include - -// This function intentionally has variable shadowing, which triggers -Wshadow -// when strict_warnings or all_wall_warnings are enabled. The test provides -// -Wno-shadow via copts, so this should compile successfully if flag ordering -// is correct. -int shadow_function(int value) { - int result = value * 2; // Outer result - int final_result = result; // Use outer result to avoid -Wunused-variable - { - // Intentional shadowing to trigger -Wshadow - int result = value * 3; // Inner result shadows outer - final_result += result; // Use inner result - } - return final_result; -} - -int main() { - std::cout << "Warning override test: shadow_function(5) = " - << shadow_function(5) << std::endl; - - std::cout << "Test passed! User -Wno-shadow flag successfully overrode " - << "the strict_warnings feature." << std::endl; - - return 0; -} diff --git a/tests/feature_verification/warnings_test.cpp b/tests/feature_verification/warnings_test.cpp deleted file mode 100644 index 48c0333..0000000 --- a/tests/feature_verification/warnings_test.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2026 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -// Test for: strict_warnings, minimal_warnings, warnings_as_errors -// This test verifies that warning levels are properly configured -// Note: This test is designed to compile WITHOUT warnings when -// strict_warnings or warnings_as_errors are disabled. - -#include -#include - -// Function to test variable shadowing (would trigger -Wshadow when strict_warnings is enabled) -int shadow_test(int value) { - int result = value * 2; - { - // This variable shadows the outer 'result' - would be caught by -Wshadow - int result = value * 3; - return result; - } -} - -// Function to test implicit conversions (would trigger -Wconversion when strict_warnings is enabled) -void conversion_test() { - double large_value = 3.14159; - int small_value = static_cast(large_value); // Explicit cast avoids warning - - uint8_t byte_val = static_cast(256); // Explicit cast - - std::cout << "Conversion test: " << small_value << " " << byte_val << std::endl; -} - -// Function to test sign conversion -void sign_conversion_test() { - int positive = 42; - unsigned int unsigned_val = static_cast(positive); - - std::cout << "Sign conversion test: " << unsigned_val << std::endl; -} - -int main() { - std::cout << "Testing warning level features..." << std::endl; - - std::cout << "Shadow test result: " << shadow_test(5) << std::endl; - conversion_test(); - sign_conversion_test(); - - std::cout << "All warning level tests completed!" << std::endl; - return 0; -}