[all-commits] [llvm/llvm-project] 552c6c: PR44406: Follow behavior of array bound constant f...

Richard Smith via All-commits all-commits at lists.llvm.org
Fri Oct 16 14:34:56 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 552c6c2328723a248c2b4d2765f75d49129dff20
      https://github.com/llvm/llvm-project/commit/552c6c2328723a248c2b4d2765f75d49129dff20
  Author: Richard Smith <richard at metafoo.co.uk>
  Date:   2020-10-16 (Fri, 16 Oct 2020)

  Changed paths:
    M clang/docs/UsersManual.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaType.cpp
    M clang/test/CXX/basic/basic.types/p10.cpp
    M clang/test/CXX/drs/dr3xx.cpp
    M clang/test/CodeGen/vla.c
    M clang/test/Misc/warning-flags.c
    M clang/test/PCH/cxx-constexpr.cpp
    M clang/test/Profile/misexpect-switch-default.c
    M clang/test/Profile/misexpect-switch-nonconst.c
    M clang/test/Profile/misexpect-switch-only-default-case.c
    M clang/test/Profile/misexpect-switch.c
    M clang/test/Sema/builtin-assume.c
    M clang/test/Sema/builtins.c
    M clang/test/Sema/complex-int.c
    M clang/test/Sema/const-eval-64.c
    M clang/test/Sema/const-eval.c
    M clang/test/Sema/darwin-align-cast.c
    M clang/test/Sema/decl-in-prototype.c
    M clang/test/Sema/gnu-flags.c
    M clang/test/Sema/i-c-e.c
    M clang/test/Sema/offsetof-64.c
    M clang/test/Sema/rounding-math.c
    M clang/test/Sema/struct-decl.c
    M clang/test/Sema/typedef-variable-type.c
    M clang/test/Sema/vla.c
    M clang/test/SemaCXX/anonymous-struct.cpp
    M clang/test/SemaCXX/constant-expression.cpp
    M clang/test/SemaCXX/cxx1z-noexcept-function-type.cpp
    M clang/test/SemaCXX/i-c-e-cxx.cpp
    M clang/test/SemaObjC/gcc-cast-ext.m

  Log Message:
  -----------
  PR44406: Follow behavior of array bound constant folding in more recent versions of GCC.

Old GCC used to aggressively fold VLAs to constant-bound arrays at block
scope in GNU mode. That's non-conforming, and more modern versions of
GCC only do this at file scope. Update Clang to do the same.

Also promote the warning for this from off-by-default to on-by-default
in all cases; more recent versions of GCC likewise warn on this by
default.

This is still slightly more permissive than GCC, as pointed out in
PR44406, as we still fold VLAs to constant arrays in structs, but that
seems justifiable given that we don't support VLA-in-struct (and don't
intend to ever support it), but GCC does.

Differential Revision: https://reviews.llvm.org/D89523




More information about the All-commits mailing list