Accept -Wno- prefix in ARI
[deliverable/binutils-gdb.git] / gdb / contrib / ari / gdb_ari.sh
index 895654150b37a833fb43a391478d56da4f4bc66c..02c3647388ccfe30368dc4f62815a1004b5e25d4 100755 (executable)
@@ -27,7 +27,7 @@ LC_ALL=C ; export LC_ALL
 
 # Permanent checks take the form:
 
-#     Do not use XXXX, ISO C 90 implies YYYY
+#     Do not use XXXX, C++11 implies YYYY
 #     Do not use XXXX, instead use YYYY''.
 
 # and should never be removed.
@@ -52,7 +52,7 @@ usage ()
 Error: $1
 
 Usage:
-    $0 --print-doc --print-idx -Wall -Werror -W<category> <file> ...
+    $0 --print-doc --print-idx -Wall -Werror -WCATEGORY FILE ...
 Options:
   --print-doc    Print a list of all potential problems, then exit.
   --print-idx    Include the problems IDX (index or key) in every message.
@@ -60,7 +60,8 @@ Options:
   -Werror        Treat all problems as errors.
   -Wall          Report all problems.
   -Wari          Report problems that should be fixed in new code.
-  -W<category>   Report problems in the specifed category.  Valid categories
+  -WCATEGORY     Report problems in the specifed category.  The category
+                 can be prefixed with "no-".  Valid categories
                  are: ${all}
 EOF
     exit 1
@@ -102,6 +103,10 @@ fi
 # Validate all errors and warnings.
 for w in ${warning} ${error}
 do
+    case "$w" in
+       no-*) w=`echo x$w | sed -e 's/xno-//'`;;
+    esac
+
     case " ${all} " in
     *" ${w} "* ) ;;
     * ) usage "Unknown option -W${w}" ;;
@@ -123,11 +128,19 @@ do
 done
 for w in ${warning}
 do
-    warnings="${warnings} warning[ari_${w}] = 1;"
+    val=1
+    case "$w" in
+       no-*) w=`echo x$w | sed -e 's/xno-//'`; val=0 ;;
+    esac
+    warnings="${warnings} warning[ari_${w}] = $val;"
 done
 for e in ${error}
 do
-    errors="${errors} error[ari_${e}]  = 1;"
+    val=1
+    case "$e" in
+       no-*) e=`echo x$e | sed -e 's/xno-//'`; val=0 ;;
+    esac
+    errors="${errors} error[ari_${e}]  = $val;"
 done
 
 if [ "$AWK" = "" ] ; then
@@ -255,17 +268,6 @@ BEGIN {
 }
 
 
-# Things in comments
-
-BEGIN { doc["ARGSUSED"] = "\
-Do not use ARGSUSED, unnecessary"
-    category["ARGSUSED"] = ari_regression
-}
-/(^|[^_[:alnum:]])ARGSUSED([^_[:alnum:]]|$)/ {
-    fail("ARGSUSED")
-}
-
-
 # SNIP - Strip out comments - SNIP
 
 FNR == 1 {
@@ -364,7 +366,8 @@ Do not use printf(\"%p\"), instead use printf(\"%s\",paddr()) to dump a \
 target address, or host_address_to_string() for a host address"
     category["%p"] = ari_code
 }
-/%p/ && !/%prec/ {
+# Allow gdb %p extensions, but not other uses of %p.
+/%p[^[\]sF]/ && !/%prec/ {
     fail("%p")
 }
 
@@ -433,27 +436,8 @@ FNR == 1 {
 cont_p { $0 = full_line $0; cont_p = 0; full_line = ""; }
 
 
-# GDB uses ISO C 90.  Check for any non pure ISO C 90 code
-
-BEGIN { doc["PARAMS"] = "\
-Do not use PARAMS(), ISO C 90 implies prototypes"
-    category["PARAMS"] = ari_regression
-}
-/(^|[^_[:alnum:]])PARAMS([^_[:alnum:]]|$)/ {
-    fail("PARAMS")
-}
-
-BEGIN { doc["__func__"] = "\
-Do not use __func__, ISO C 90 does not support this macro"
-    category["__func__"] = ari_regression
-    fix("__func__", "gdbsupport/gdb_assert.h", 1)
-}
-/(^|[^_[:alnum:]])__func__([^_[:alnum:]]|$)/ {
-    fail("__func__")
-}
-
 BEGIN { doc["__FUNCTION__"] = "\
-Do not use __FUNCTION__, ISO C 90 does not support this macro"
+Do not use __FUNCTION__, C++11 does not support this macro"
     category["__FUNCTION__"] = ari_regression
 }
 /(^|[^_[:alnum:]])__FUNCTION__([^_[:alnum:]]|$)/ {
@@ -470,7 +454,7 @@ autoconf tests"
 }
 
 BEGIN { doc["PTR"] = "\
-Do not use PTR, ISO C 90 implies `void *'\''"
+Do not use PTR, C++11 implies `void *'\''"
     category["PTR"] = ari_regression
     #fix("PTR", "gdb/utils.c", 6)
 }
@@ -610,17 +594,6 @@ Do not use `long long'\'', instead use LONGEST"
     fail("long long")
 }
 
-BEGIN { doc["ATTRIBUTE_UNUSED"] = "\
-Do not use ATTRIBUTE_UNUSED, do not bother (GDB is compiled with -Werror and, \
-consequently, is not able to tolerate false warnings.  Since -Wunused-param \
-produces such warnings, neither that warning flag nor ATTRIBUTE_UNUSED \
-are used by GDB"
-    category["ATTRIBUTE_UNUSED"] = ari_regression
-}
-/(^|[^_[:alnum:]])ATTRIBUTE_UNUSED([^_[:alnum:]]|$)/ {
-    fail("ATTRIBUTE_UNUSED")
-}
-
 BEGIN { doc["ATTR_FORMAT"] = "\
 Do not use ATTR_FORMAT, use ATTRIBUTE_PRINTF instead"
     category["ATTR_FORMAT"] = ari_regression
@@ -687,7 +660,6 @@ FNR == 1 {
 BEGIN { doc["abort"] = "\
 Do not use abort, instead use internal_error; GDB should never abort"
     category["abort"] = ari_regression
-    fix("abort", "gdb/utils.c", 3)
 }
 /(^|[^_[:alnum:]])abort[[:space:]]*\(/ {
     fail("abort")
@@ -816,7 +788,7 @@ unconditionally"
 }
 
 BEGIN { doc["bcmp"] = "\
-Do not use bcmp(), ISO C 90 implies memcmp()"
+Do not use bcmp(), C++11 implies memcmp()"
     category["bcmp"] = ari_regression
 }
 /(^|[^_[:alnum:]])bcmp[[:space:]]*\(/ {
@@ -824,7 +796,7 @@ Do not use bcmp(), ISO C 90 implies memcmp()"
 }
 
 BEGIN { doc["setlinebuf"] = "\
-Do not use setlinebuf(), ISO C 90 implies setvbuf()"
+Do not use setlinebuf(), C++11 implies setvbuf()"
     category["setlinebuf"] = ari_regression
 }
 /(^|[^_[:alnum:]])setlinebuf[[:space:]]*\(/ {
@@ -832,7 +804,7 @@ Do not use setlinebuf(), ISO C 90 implies setvbuf()"
 }
 
 BEGIN { doc["bcopy"] = "\
-Do not use bcopy(), ISO C 90 implies memcpy() and memmove()"
+Do not use bcopy(), C++11 implies memcpy() and memmove()"
     category["bcopy"] = ari_regression
 }
 /(^|[^_[:alnum:]])bcopy[[:space:]]*\(/ {
@@ -851,7 +823,6 @@ get_frame_locals_address, or get_frame_args_address."
 BEGIN { doc["floatformat_to_double"] = "\
 Do not use floatformat_to_double() from libierty, \
 instead use floatformat_to_doublest()"
-    fix("floatformat_to_double", "gdb/doublest.c", 1)
     category["floatformat_to_double"] = ari_regression
 }
 /(^|[^_[:alnum:]])floatformat_to_double[[:space:]]*\(/ {
@@ -860,7 +831,7 @@ instead use floatformat_to_doublest()"
 
 BEGIN { doc["floatformat_from_double"] = "\
 Do not use floatformat_from_double() from libierty, \
-instead use floatformat_from_doublest()"
+instead use host_float_ops<T>::from_target()"
     category["floatformat_from_double"] = ari_regression
 }
 /(^|[^_[:alnum:]])floatformat_from_double[[:space:]]*\(/ {
@@ -1139,18 +1110,6 @@ Do not use strnicmp(), instead use strncasecmp()"
     fail("strnicmp")
 }
 
-# Boolean expressions and conditionals
-
-BEGIN { doc["boolean"] = "\
-Do not use `boolean'\'',  use `bool'\'' instead"
-    category["boolean"] = ari_regression
-}
-/(^|[^_[:alnum:]])boolean([^_[:alnum:]]|$)/ {
-    if (is_yacc_or_lex == 0) {
-       fail("boolean")
-    }
-}
-
 # Typedefs that are either redundant or can be reduced to `struct
 # type *''.
 # Must be placed before if assignment otherwise ARI exceptions
@@ -1172,20 +1131,6 @@ Do not use strlen dirent.d_name, instead use NAMELEN"
     fail("strlen d_name")
 }
 
-BEGIN { doc["var_boolean"] = "\
-Replace var_boolean with add_setshow_boolean_cmd"
-    category["var_boolean"] = ari_regression
-    fix("var_boolean", "gdb/command.h", 1)
-    # fix only uses the last directory level
-    fix("var_boolean", "cli/cli-decode.c", 2)
-}
-/(^|[^_[:alnum:]])var_boolean([^_[:alnum:]]|$)/ {
-    if (($0 !~ /(^|[^_[:alnum:]])case *var_boolean:/) \
-        && ($0 !~ /(^|[^_[:alnum:]])[=!]= *var_boolean/)) {
-       fail("var_boolean")
-    }
-}
-
 BEGIN { doc["generic_use_struct_convention"] = "\
 Replace generic_use_struct_convention with nothing, \
 EXTRACT_STRUCT_VALUE_ADDRESS is a predicate"
This page took 0.026679 seconds and 4 git commands to generate.