]> granicus.if.org Git - vim/commitdiff
patch 8.2.3770: new compiler warnings from clang-12 and clang-13 v8.2.3770
authorichizok <gclient.gaap@gmail.com>
Thu, 9 Dec 2021 21:08:01 +0000 (21:08 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 9 Dec 2021 21:08:01 +0000 (21:08 +0000)
Problem:    New compiler warnings from clang-12 and clang-13.
Solution:   Adjust CI and suppress some warnings. (Ozaki Kiichi, closes #9314)

.github/workflows/ci.yml
ci/config.mk.clang-12.sed [new file with mode: 0644]
src/os_unix.c
src/spellfile.c
src/version.c

index 99223229f98aacbd99677ea4563771a0dd1a3f14..19952df178168be66a54769c92ddf3c9b22e619a 100644 (file)
@@ -75,16 +75,16 @@ jobs:
             libtool-bin \
             libsodium-dev
 
-      - name: Install clang-11
+      - name: Install clang-13
         if: matrix.compiler == 'clang'
         run: |
           wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
           . /etc/lsb-release
-          sudo add-apt-repository -y "deb http://apt.llvm.org/${DISTRIB_CODENAME}/ llvm-toolchain-${DISTRIB_CODENAME}-11 main"
-          sudo apt-get install -y clang-11 llvm-11
-          sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-11 100
-          sudo update-alternatives --set clang /usr/bin/clang-11
-          sudo update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-11 100
+          sudo add-apt-repository -y "deb http://apt.llvm.org/${DISTRIB_CODENAME}/ llvm-toolchain-${DISTRIB_CODENAME}-13 main"
+          sudo apt-get install -y clang-13 llvm-13
+          sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-13 100
+          sudo update-alternatives --set clang /usr/bin/clang-13
+          sudo update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-13 100
 
       - name: Set up environment
         run: |
@@ -188,6 +188,10 @@ jobs:
           # Append various warning flags to CFLAGS.
           sed -i -f ci/config.mk.sed ${SRCDIR}/auto/config.mk
           sed -i -f ci/config.mk.${CC}.sed ${SRCDIR}/auto/config.mk
+          if [[ ${CC} = clang ]]; then
+            # Suppress some warnings produced by clang 12 and later.
+            sed -i -f ci/config.mk.clang-12.sed ${SRCDIR}/auto/config.mk
+          fi
 
       - name: Build
         if: (!contains(matrix.extra, 'unittests'))
@@ -296,6 +300,10 @@ jobs:
           sed -i.bak -f ci/config.mk.sed ${SRCDIR}/auto/config.mk
           # On macOS, the entity of gcc is clang.
           sed -i.bak -f ci/config.mk.clang.sed ${SRCDIR}/auto/config.mk
+          # Suppress some warnings produced by clang 12 and later.
+          if clang --version | grep -qs 'Apple clang version \(1[3-9]\|[2-9]\)\.'; then
+            sed -i.bak -f ci/config.mk.clang-12.sed ${SRCDIR}/auto/config.mk
+          fi
 
       - name: Build
         env:
diff --git a/ci/config.mk.clang-12.sed b/ci/config.mk.clang-12.sed
new file mode 100644 (file)
index 0000000..e305c59
--- /dev/null
@@ -0,0 +1,3 @@
+# Clang 12 (or Apple clang 13) and later makes a warning '-Wcompound-token-split-by-macro' enable by default.
+/^PERL_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=compound-token-split-by-macro/
+/^RUBY_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=compound-token-split-by-macro/
index 32850f3bf2f2f71de06c178ded807d811b8497cb..1c00f22793e99ed77333720d6ec104df7d44fd49 100644 (file)
@@ -3376,7 +3376,15 @@ exit_scroll(void)
 }
 
 #ifdef USE_GCOV_FLUSH
-extern void __gcov_flush();
+# if (defined(__GNUC__) \
+           && ((__GNUC__ == 11 && __GNUC_MINOR__ >= 1) || (__GNUC__ >= 12))) \
+       || (defined(__clang__) && (__clang_major__ >= 12))
+extern void __gcov_dump(void);
+extern void __gcov_reset(void);
+#  define __gcov_flush() do { __gcov_dump(); __gcov_reset(); } while (0)
+# else
+extern void __gcov_flush(void);
+# endif
 #endif
 
     void
index 6d6c248ab03e43466ba54fbc34cf16d555b37ead..46d222d9b7da6eb9626fe6d335d3a6bd4be75609 100644 (file)
@@ -6576,7 +6576,7 @@ write_spell_prefcond(FILE *fd, garray_T *gap)
     char_u     *p;
     int                len;
     int                totlen;
-    size_t     x = 1;  // collect return value of fwrite()
+    size_t     x UNUSED = 1;  // collect return value of fwrite()
 
     if (fd != NULL)
        put_bytes(fd, (long_u)gap->ga_len, 2);      // <prefcondcnt>
index 5aa6ce73e0639395b81157d9262e842ac9c141f8..5db7dca5d8f2153487a2df10ed91dc29bab40c1e 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3770,
 /**/
     3769,
 /**/