Skip to content

Commit

Permalink
Merge bitcoin-core/secp256k1#1206: build: Add -Wreserved-identifier s…
Browse files Browse the repository at this point in the history
…upported by clang

8c7e0fc build: Add -Wreserved-identifier supported by clang (Tim Ruffing)

Pull request description:

  This warns on certain identifiers reserved by the C standard, namely
   * identifiers that begin with an underscore followed by an uppercase letter, and
   * identifiers in the global namespace that begin with an underscore.

  We had used such identifiers in the past for macros in include guards, and we should make sure that we don't reintroduce such identifiers going forward.

  Note that C reserves more identifiers for "future library directions", e.g., identifiers that begin with "str" followed by a lowercase letter. But even the C standards committee has decided that this is somewhat silly and adopted a proposal [1] for C23 that removes the restriction that programs using these identifiers have UB. Instead, these identifiers are now "potentially reserved", which is not a normative restriction but simply an informative warning that the identifiers may become fully reserved in the future.

  [1] https://www.open-std.org/jtc1/sc22/WG14/www/docs/n2625.pdf

ACKs for top commit:
  sipa:
    utACK 8c7e0fc
  jonasnick:
    tested ACK 8c7e0fc

Tree-SHA512: da0c5f1e36cffad2ab2f0b8055c8b3cb56e904d8bfea5a9eed9d6fa984359217b3ef3b9232bfb455cf4071c04a6c2a077e26d2a15b20d1eabc99b1fc61d2025c
  • Loading branch information
real-or-random committed Feb 3, 2023
2 parents 8ebe5c5 + 8c7e0fc commit 1cca7c1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [
SECP_TRY_APPEND_CFLAGS([-Wcast-align], $1) # GCC >= 2.95
SECP_TRY_APPEND_CFLAGS([-Wcast-align=strict], $1) # GCC >= 8.0
SECP_TRY_APPEND_CFLAGS([-Wconditional-uninitialized], $1) # Clang >= 3.0 only
SECP_TRY_APPEND_CFLAGS([-Wreserved-identifier], $1) # Clang >= 13.0 only
SECP_TRY_APPEND_CFLAGS([-fvisibility=hidden], $1) # GCC >= 4.0
CFLAGS="$SECP_TRY_APPEND_DEFAULT_CFLAGS_saved_CFLAGS"
Expand Down

0 comments on commit 1cca7c1

Please sign in to comment.