[PATCH] diagnosing flexible array assignments
Eli Friedman
eli.friedman at gmail.com
Tue Sep 10 14:21:21 PDT 2013
On Tue, Sep 10, 2013 at 2:03 PM, Aaron Ballman <aaron at aaronballman.com>wrote:
> Currently, if you have a value assignment involving structures
> containing a flexible array, no diagnostic is emitted. However, since
> the array members won't be copied as part of the assignment, a
> diagnostic will help programmers avoid bugs. This patch emits said
> diagnostic.
>
>
+def warn_flexible_array_assignment : ExtWarn<
+ "assignment of flexible arrays does not copy the array members">,
+ InGroup<FlexibleArrayExtensions>;
I assume this is supposed to be a Warning, not an ExtWarn?
Also, I'm not sure putting this into the FlexibleArrayExtensions diagnostic
group is the best idea.
What sort of mistakes do you expect this to catch in practice?
Have you considered warning about the variable declaration rather than the
assignment? In your testcase, it's impossible to call foo() without
triggering the warning, so it seems better to warn about foo() itself
rather than the call.
-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130910/6e871eca/attachment.html>
More information about the cfe-commits
mailing list