public void checkForLabelConflicts(Collection<Rule> rules) {
		for (Rule r : rules) {
			checkForAttributeConflicts(r);

			Map<String, LabelElementPair> labelNameSpace = new HashMap<>();
			for (int i = 1; i <= r.numberOfAlts; i++) {
				Alternative a = r.alt[i];
				for (List<LabelElementPair> pairs : a.labelDefs.values()) {
					if (r.hasAltSpecificContexts()) {
						// Collect labelName-labeledRules map for rule with alternative labels.
						Map<String, List<LabelElementPair>> labelPairs = new HashMap<>();
						for (LabelElementPair p : pairs) {
							String labelName = findAltLabelName(p.label);
							if (labelName != null) {
								List<LabelElementPair> list;
								if (labelPairs.containsKey(labelName)) {
									list = labelPairs.get(labelName);
								}
								else {
									list = new ArrayList<>();
									labelPairs.put(labelName, list);
								}
								list.add(p);
							}
						}

						for (List<LabelElementPair> internalPairs : labelPairs.values()) {
							labelNameSpace.clear();
							checkLabelPairs(r, labelNameSpace, internalPairs);
						}
					}
					else {
						checkLabelPairs(r, labelNameSpace, pairs);
					}
				}
			}
		}
	}
Make sure a label doesn't conflict with another symbol.
Labels must not conflict with: rules, tokens, scope names,
return values, parameters, and rule-scope dynamic attributes
defined in surrounding rule.  Also they must have same type
for repeated defs.
tool/src/org/antlr/v4/semantics/SymbolChecks.java