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