+ // Find all of the named values in the input and output, ensure they have the
+ // same type.
+ std::map<std::string, const TreePatternNode*> SrcNames, DstNames;
+ FindNames(PTM.getSrcPattern(), SrcNames);
+ FindNames(PTM.getDstPattern(), DstNames);
+
+ // Scan all of the named values in the destination pattern, rejecting them if
+ // they don't exist in the input pattern.
+ for (std::map<std::string, const TreePatternNode*>::iterator
+ I = DstNames.begin(), E = DstNames.end(); I != E; ++I)
+ if (SrcNames[I->first] == 0)
+ Pattern->error("Pattern has input without matching name in output: $" +
+ I->first);
+