[PATCH] D156565: Diagnose use of VLAs in C++ by default

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 29 08:07:11 PDT 2023


aaron.ballman updated this revision to Diff 557483.
aaron.ballman added a comment.

Updated based on feedback on the RFC. Specifically, this variant recognizes `int array[cond ? 1 : -1];` or similar constructs and recommends using a `static_assert` instead. This new diagnostic is under its own warning group (`-Wvla-extension-static-assert`) so that users who want to be alerted to use of VLAs but not static_assert-like VLAs can do so, but the new warning group is still under `-Wvla-extension` and thus is enabled similarly.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156565/new/

https://reviews.llvm.org/D156565

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/Analysis/lambdas.cpp
  clang/test/CXX/basic/basic.types/p10.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
  clang/test/Misc/warning-wall.c
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/parallel_ast_print.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_masked_ast_print.cpp
  clang/test/OpenMP/parallel_master_ast_print.cpp
  clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_private_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_reduction_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_reduction_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/target_ast_print.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_constant_device_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_defaultmap_messages.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_has_device_addr_codegen_01.cpp
  clang/test/OpenMP/target_in_reduction_codegen.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_18a.cpp
  clang/test/OpenMP/target_map_codegen_18b.cpp
  clang/test/OpenMP/target_map_codegen_18c.cpp
  clang/test/OpenMP/target_map_codegen_18d.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_defaultmap_messages.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_generic_loop_depend_codegen.cpp
  clang/test/OpenMP/target_private_codegen.cpp
  clang/test/OpenMP/target_reduction_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_generic_loop_depend_codegen.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp
  clang/test/OpenMP/task_ast_print.cpp
  clang/test/OpenMP/task_codegen.cpp
  clang/test/OpenMP/task_firstprivate_codegen.cpp
  clang/test/OpenMP/task_in_reduction_codegen.cpp
  clang/test/OpenMP/task_private_codegen.cpp
  clang/test/OpenMP/taskgroup_task_reduction_codegen.cpp
  clang/test/OpenMP/taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/taskloop_private_codegen.cpp
  clang/test/OpenMP/taskloop_reduction_codegen.cpp
  clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/taskloop_simd_reduction_codegen.cpp
  clang/test/OpenMP/teams_distribute_codegen.cpp
  clang/test/OpenMP/teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_firstprivate_codegen.cpp
  clang/test/OpenMP/teams_generic_loop_codegen-1.cpp
  clang/test/Parser/objcxx11-attributes.mm
  clang/test/Parser/pragma-loop.cpp
  clang/test/Sema/vla.cpp
  clang/test/Sema/wasm-refs-and-tables.c
  clang/test/SemaCUDA/call-stack-for-deferred-err.cu
  clang/test/SemaCUDA/no-call-stack-for-immediate-errs.cu
  clang/test/SemaCUDA/vla.cu
  clang/test/SemaCXX/PR10177.cpp
  clang/test/SemaCXX/alias-template.cpp
  clang/test/SemaCXX/anonymous-struct.cpp
  clang/test/SemaCXX/c99-variable-length-array-cxx11.cpp
  clang/test/SemaCXX/c99-variable-length-array.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constexpr-array-unknown-bound.cpp
  clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
  clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
  clang/test/SemaCXX/cxx1z-noexcept-function-type.cpp
  clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp
  clang/test/SemaCXX/exceptions.cpp
  clang/test/SemaCXX/for-range-examples.cpp
  clang/test/SemaCXX/i-c-e-cxx.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/new-delete-0x.cpp
  clang/test/SemaCXX/new-delete.cpp
  clang/test/SemaCXX/offsetof.cpp
  clang/test/SemaCXX/paren-list-agg-init.cpp
  clang/test/SemaCXX/vararg-non-pod.cpp
  clang/test/SemaCXX/vla-construct.cpp
  clang/test/SemaCXX/vla-ext-diag.cpp
  clang/test/SemaCXX/vla.cpp
  clang/test/SemaCXX/warn-unused-lambda-capture.cpp
  clang/test/SemaCXX/warn-unused-variables.cpp
  clang/test/SemaObjCXX/properties.mm
  clang/test/SemaObjCXX/vla.mm
  clang/test/SemaSYCL/unique_stable_name.cpp
  clang/test/SemaTemplate/concepts-out-of-line-def.cpp
  clang/test/SemaTemplate/deduction.cpp
  clang/test/SemaTemplate/instantiate-sizeof.cpp
  clang/test/SemaTemplate/instantiate-typeof.cpp



More information about the cfe-commits mailing list