[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible arrays
serge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 11 02:07:18 PDT 2022
serge-sans-paille added a comment.
@kees are you ok with current state?
================
Comment at: clang/lib/CodeGen/CGExpr.cpp:906
// member, only a T[0] or T[] member gets that treatment.
+ // Under StrictFlexArraysLevel, obey c99+ that disallows FAM in union, see
+ // C11 6.7.2.1 ยง18
----------------
jyknight wrote:
> I believe this bit is incorrect -- it should just go back to 'return true;'. The StrictFlexArraysLevel check above already eliminates the cases we want to eliminate (size==1 in strictness-level 2.)
Well, if we are in strictness-level 2, with an undefined size or size = 0, we can still reach that path, and don't want to return 'true' because FAM in union are in invalid per the standard.
================
Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:792
+ if (getContext().getLangOpts().StrictFlexArrays >= 2)
+ return false;
----------------
jyknight wrote:
> Yuk, another place that is weird and doesn't handle StrictFlexArrays as expected...
I've been able to slightly move that check below, without impacting test suite. Also added a FIXME because `Opts.ShouldConsiderSingleElementArraysAsFlexibleArrayMembers` looks redundant with `-fstrict-flex-arrays`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126864/new/
https://reviews.llvm.org/D126864
More information about the cfe-commits
mailing list