]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
Add syntax-check rule against compiler predef misspellings.
authorBruno Haible <bruno@clisp.org>
Wed, 7 May 2025 08:52:49 +0000 (10:52 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 7 May 2025 08:52:49 +0000 (10:52 +0200)
* Makefile (sc_prohibit_misspelled_compiler_predefs): New target.

ChangeLog
Makefile

index 738dce26d259cbf481d88782838bc4cdaf8d9df2..6d1e5f8e3d372ed270185940ab7899528ebe8baa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2025-05-07  Bruno Haible  <bruno@clisp.org>
+
+       Add syntax-check rule against compiler predef misspellings.
+       * Makefile (sc_prohibit_misspelled_compiler_predefs): New target.
+
 2025-05-07  Bruno Haible  <bruno@clisp.org>
 
        Remove obsolete syntax-check rules.
index b2d0cec897403add71bb34a012bf90a9d4424daf..767c6eeb6fbbbf4f3bd7410a0cbdf74fe7729b46 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -53,6 +53,23 @@ sc_prohibit_leading_TABs:
 exclude_file_name_regexp--sc_prohibit_leading_TABs = \
   ^(lib/(cdefs\.h|getopt|ieee754|malloc/|mini-|mktime\.c|qsort\.c|reg|strverscmp\.c)|m4/(largefile|std-gnu)|m4/libgcrypt|tests/from-glibc/|tests/test-update-copyright|Makefile|.*/Makefile)
 
+# Cf. <https://github.com/cpredef/predef/blob/master/Compilers.md>
+sc_prohibit_misspelled_compiler_predefs:
+       if test -d .git; then                                           \
+         git ls-files m4 lib tests                                     \
+           | xargs grep -Ew '($(misspelled_compiler_predefs_or))'              \
+           && { printf '*** %s\n' 'misspelled predefs' 1>&2; exit 1; } \
+           || :                                                        \
+       else :; fi
+misspelled_compiler_predefs_or = $(shell echo $(misspelled_compiler_predefs) | tr -s ' ' '|')
+misspelled_compiler_predefs =\
+  __clang_major                \
+  __clang_minor                \
+  __GNUC               \
+  __GNUC_MAJOR         \
+  __GNUC_MAJOR__       \
+  __GNUC_MINOR         \
+
 sc_prohibit_augmenting_PATH_via_TESTS_ENVIRONMENT:
        if test -d .git; then                                           \
          url=https://lists.gnu.org/r/bug-gnulib/2010-09/msg00064.html; \