Warn on unsupported fortification levels
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 10 Dec 2020 11:17:02 +0000 (16:47 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 31 Dec 2020 11:25:21 +0000 (16:55 +0530)
Make the _FORTIFY_SOURCE macro soup in features.h warn about
unsupported fortification levels.  For example, it will warn about
_FORTIFY_SOURCE=3 and over with an indication of which level has been
selected.

Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
include/features.h

index f3e62d3362b79b2f0278d31882f48c9970f0c169..540230b90b55279676e46d732deb21eb9d760790 100644 (file)
 # elif !__GNUC_PREREQ (4, 1)
 #  warning _FORTIFY_SOURCE requires GCC 4.1 or later
 # elif _FORTIFY_SOURCE > 1
+#  if _FORTIFY_SOURCE > 2
+#   warning _FORTIFY_SOURCE > 2 is treated like 2 on this platform
+#  endif
 #  define __USE_FORTIFY_LEVEL 2
 # else
 #  define __USE_FORTIFY_LEVEL 1