[all-commits] [llvm/llvm-project] dc1ab5: [Sema] Fold VLA types in compound literals to cons...

Eli Friedman via All-commits all-commits at lists.llvm.org
Wed Apr 14 17:10:33 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dc1ab590a0527533815aeed0100de54a5f4a4829
      https://github.com/llvm/llvm-project/commit/dc1ab590a0527533815aeed0100de54a5f4a4829
  Author: Eli Friedman <efriedma at quicinc.com>
  Date:   2021-04-14 (Wed, 14 Apr 2021)

  Changed paths:
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/test/Sema/vla.c

  Log Message:
  -----------
  [Sema] Fold VLA types in compound literals to constant arrays.

Similar to variables with an initializer, this is never valid in
standard C, so we can safely constant-fold as an extension.  I ran into
this construct in a couple proprietary codebases.

While I'm here, drive-by fix for 090dd647: we should only fold variables
with VLA types, not arbitrary variably modified types.

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




More information about the All-commits mailing list