* genrecog.c (validate_pattern): Check matching constraint refers
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Apr 2015 18:40:43 +0000 (18:40 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Apr 2015 18:40:43 +0000 (18:40 +0000)
        to a lower numbered operand.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222418 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/genrecog.c

index 025289e..1995751 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-24  Chen Gang  <gang.chen.5i5j@gmail.com>
+
+       * genrecog.c (validate_pattern): Check matching constraint refers
+       to a lower numbered operand.
+
 2015-04-24  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/65849
index 81a0e79..9367d74 100644 (file)
@@ -503,7 +503,8 @@ validate_pattern (rtx pattern, rtx insn, rtx set, int set_code)
 
        if (code == MATCH_OPERAND)
          {
-           const char constraints0 = XSTR (pattern, 2)[0];
+           const char *constraints = XSTR (pattern, 2);
+           const char constraints0 = constraints[0];
 
            if (!constraints_supported_in_insn_p (insn))
              {
@@ -537,6 +538,33 @@ validate_pattern (rtx pattern, rtx insn, rtx set, int set_code)
                                   "operand %d missing output reload",
                                   XINT (pattern, 0));
              }
+
+           /* For matching constraint in MATCH_OPERAND, the digit must be a
+              smaller number than the number of the operand that uses it in the
+              constraint.  */
+           while (1)
+             {
+               while (constraints[0]
+                      && (constraints[0] == ' ' || constraints[0] == ','))
+                 constraints++;
+               if (!constraints[0])
+                 break;
+
+               if (constraints[0] >= '0' && constraints[0] <= '9')
+                 {
+                   int val;
+
+                   sscanf (constraints, "%d", &val);
+                   if (val >= XINT (pattern, 0))
+                     error_with_line (pattern_lineno,
+                                      "constraint digit %d is not smaller than"
+                                      " operand %d",
+                                      val, XINT (pattern, 0));
+                 }
+
+               while (constraints[0] && constraints[0] != ',')
+                 constraints++;
+             }
          }
 
        /* Allowing non-lvalues in destinations -- particularly CONST_INT --