c5d972
commit 2a08b6e8331a611dc29325bfa6e29fecc9a3a46e
c5d972
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
c5d972
Date:   Thu Dec 10 16:47:02 2020 +0530
c5d972
c5d972
    Warn on unsupported fortification levels
c5d972
    
c5d972
    Make the _FORTIFY_SOURCE macro soup in features.h warn about
c5d972
    unsupported fortification levels.  For example, it will warn about
c5d972
    _FORTIFY_SOURCE=3 and over with an indication of which level has been
c5d972
    selected.
c5d972
    
c5d972
    Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
c5d972
c5d972
diff --git a/include/features.h b/include/features.h
c5d972
index 5bed0a499605a3a2..ea7673ee115bcf0a 100644
c5d972
--- a/include/features.h
c5d972
+++ b/include/features.h
c5d972
@@ -382,6 +382,9 @@
c5d972
 # elif !__GNUC_PREREQ (4, 1)
c5d972
 #  warning _FORTIFY_SOURCE requires GCC 4.1 or later
c5d972
 # elif _FORTIFY_SOURCE > 1
c5d972
+#  if _FORTIFY_SOURCE > 2
c5d972
+#   warning _FORTIFY_SOURCE > 2 is treated like 2 on this platform
c5d972
+#  endif
c5d972
 #  define __USE_FORTIFY_LEVEL 2
c5d972
 # else
c5d972
 #  define __USE_FORTIFY_LEVEL 1