[PATCH] D85545: [Diagnostics] Diagnose missing comma in string array initialization

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 7 14:29:39 PDT 2020


xbolva00 added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:6916
+        for (unsigned i = 0; i < numConcat; ++i)
+          if (SL->getStrTokenLoc(i).isMacroID()) {
+            hasMacro = true;
----------------
Quuxplusone wrote:
> I wonder if perhaps the warning should trigger only if the concatenated pieces appear one-per-line, i.e., whitespace-sensitive.
> 
>     const char a[] = {
>         "a"
>         "b"
>     };
>     const char b[] = {
>         "b" "c"
>     };
> 
> It's at least arguable that `a` is a bug and `b` is intentional, based purely on how the whitespace appears. OTOH, whitespace is not preserved by clang-format, and it would suck for clang-formatting the code to cause the appearance (or disappearance) of diagnostics.
Hard to tell, no strong opinion.

We can always decrease the "power" of warning based on external feedback.


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

https://reviews.llvm.org/D85545



More information about the cfe-commits mailing list