{"record":{"id":"6c574bd900f7091a","repo":"openjdk/jdk","slug":"error-context-s-c-s","errorCode":null,"errorMessage":"Error Context:  %s>>>%c<<<%s\n","messagePattern":"Error Context:  (.+?)>>>%c<<<(.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hotspot/share/adlc/adlparse.cpp","lineNumber":5052,"sourceCode":"    _AD._semantic_errs += _AD.emit_msg(0, flag, linenum(), fmt, args);\n  else\n    _AD._warnings += _AD.emit_msg(0, flag, linenum(), fmt, args);\n\n  int error_char = _curchar;\n  char* error_ptr = _ptr+1;\n  for(;*_ptr != '\\n'; _ptr++) ; // Skip to the end of the current line\n  _curchar = '\\n';\n  va_end(args);\n  _AD._no_output = 1;\n\n  if (flag == 1) {\n    char* error_tail = strchr(error_ptr, '\\n');\n    char tem = *error_ptr;\n    error_ptr[-1] = '\\0';\n    char* error_head = error_ptr-1;\n    while (error_head > _curline && *error_head)  --error_head;\n    if (error_tail)  *error_tail = '\\0';\n    fprintf(stderr, \"Error Context:  %s>>>%c<<<%s\\n\",\n            error_head, error_char, error_ptr);\n    if (error_tail)  *error_tail = '\\n';\n    error_ptr[-1] = tem;\n  }\n}\n\n//---------------------------ensure_start_of_line------------------------------\n// A preprocessor directive has been encountered.  Be sure it has fallen at\n// the beginning of a line, or else report an error.\nvoid ADLParser::ensure_start_of_line(void) {\n  if (_curchar == '\\n') { next_line(); return; }\n  assert( _ptr >= _curline && _ptr < _curline+strlen(_curline),\n          \"Must be able to find which line we are in\" );\n\n  for (char *s = _curline; s < _ptr; s++) {\n    if (*s > ' ') {\n      parse_err(SYNERR, \"'%c' must be at beginning of line\\n\", _curchar);\n      break;","sourceCodeStart":5034,"sourceCodeEnd":5070,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/hotspot/share/adlc/adlparse.cpp#L5034-L5070","documentation":"ADLC's error-context printer: when a syntax error is flagged (flag == 1), ADLParser reprints the offending line as 'Error Context: <head>>>> <char> <<<tail>' — the text before the erroring character, the character itself between '>>>' and '<<<', and the rest of the line. It is a diagnostic aid that accompanies the actual error message, produced by rewriting the in-memory line buffer (temporarily NUL-terminating head and tail).","triggerScenarios":"Any ADLParser::parse_err(..., 1) call: bad token in a .ad file triggers sync-to-end-of-line, then this context dump showing exactly which character the parser choked on.","commonSituations":"Interpreting adlc failure logs while editing .ad files; the caret-style pointer removes guesswork about which character of a long match-rule line is malformed.","solutions":["Fix the character immediately after the '>>>' marker in the referenced .ad file line","Use the head/tail text to locate the exact construct (instruction, operand, encode clause)","Rerun adlc to confirm the context no longer appears"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the >>>c<<< marker to target the exact character to fix","Re-run adlc after each single fix to keep contexts meaningful","Keep .ad lines short so context lines stay readable"],"tags":["adlc","diagnostics","syntax-error","build","hotspot"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}