genrecog.c (did_you_mean_codes): New.
authorDJ Delorie <dj@redhat.com>
Thu, 23 Dec 2004 20:21:08 +0000 (15:21 -0500)
committerDJ Delorie <dj@gcc.gnu.org>
Thu, 23 Dec 2004 20:21:08 +0000 (15:21 -0500)
* genrecog.c (did_you_mean_codes): New.
(compute_predicate_codes): Fail unmatched codes.

From-SVN: r92565

gcc/ChangeLog
gcc/genrecog.c

index 287eb53f1b48f05bc459822f14dd7647b7e32d14..9f8e174b30da5ffea76188be56f8484872840a55 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-23  DJ Delorie  <dj@redhat.com>
+
+       * genrecog.c (did_you_mean_codes): New.
+       (compute_predicate_codes): Fail unmatched codes.
+
 2004-12-23  Eric Christopher  <echristo@redhat.com>
 
        * config/mips/mips.h (TARGET_CPU_CPP_BUILTINS): Add
index 64cd905b0caab8c05322ec07daa7095819519234..2936f80afc7a45189954a60e7e5351f1bf3f1a55 100644 (file)
@@ -226,6 +226,9 @@ static int error_count;
 #define TRISTATE_NOT(a)                                \
   ((a) == I ? I : !(a))
 
+/* 0 means no warning about that code yet, 1 means warned.  */
+static char did_you_mean_codes[NUM_RTX_CODE];
+
 /* Recursively calculate the set of rtx codes accepted by the
    predicate expression EXP, writing the result to CODES.  */
 static void
@@ -285,14 +288,30 @@ compute_predicate_codes (rtx exp, char codes[NUM_RTX_CODE])
        while ((code = scan_comma_elt (&next_code)) != 0)
          {
            size_t n = next_code - code;
+           int found_it = 0;
            
            for (i = 0; i < NUM_RTX_CODE; i++)
              if (!strncmp (code, GET_RTX_NAME (i), n)
                  && GET_RTX_NAME (i)[n] == '\0')
                {
                  codes[i] = Y;
+                 found_it = 1;
                  break;
                }
+           if (!found_it)
+             {
+               message_with_line (pattern_lineno, "match_code \"%.*s\" matches nothing", n, code);
+               error_count ++;
+               for (i = 0; i < NUM_RTX_CODE; i++)
+                 if (!strncasecmp (code, GET_RTX_NAME (i), n)
+                     && GET_RTX_NAME (i)[n] == '\0'
+                     && !did_you_mean_codes[i])
+                   {
+                     did_you_mean_codes[i] = 1;
+                     message_with_line (pattern_lineno, "(did you mean \"%s\"?)", GET_RTX_NAME (i));
+                   }
+             }
+
          }
       }
       break;