Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 395
    • Issues 395
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 24
    • Merge requests 24
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2282
Closed
Open
Created Jan 19, 2022 by Michiel Verloop@MVerloopMaintainer

Streamlining errors and warnings

Currently, all errors, warnings and notes (here: messages) go through the various functions in /src/libsac2c/global/ctinfo.c.
For these messages, the file and location are printed if they are present and relevant. For longer messages, they are split up and joined by a new line and one of the seperators "abort: ", "error: ", "warning: ", "=> ", "", " ".

An example of this can be seen by compiling any valid sac file and giving the -printstart compiler argument without also providing -printstop:

$ sac2c generic_error.sac -printstart 1:prs
error: Please use both -printstart <phase_id> and -printstop <phase_id>
error: If it is only one phase/subphase/cyclephase you want reported
error: then the -printstart and -printstop options should be identical.
compilation failed while Loading SAC program, 1 error(s).

If multiple such errors appear after each other, it's impossible for a computer to tell where the first error ends and the second error begins. For humans, I argue the distinction between the two errors wouldn't be immediately obvious either. Additionally, type errors and SAC optimization errors currently differ in format from the other errors for no discernable reason.

In an effort to make the messages from the compiler parsable by regexes without ambiguity and to increase readability, I propose the following:

  • The error message is only printed on the first line if the message bears no location information.
  • The error message is always printed on a subsequent line if the file, line and/or column is known.
  • The message header (abort/error/warning) is included in the function that determines where to place line breaks.
  • Type errors are unified with the other errors.
  • We capitalize the message headers and 'compilation' properly. (Arguably not important but this bugs me more than it should)
Current vs proposed message forms (click to expand)
Errors without location information Current:
$ sac2c generic_error.sac -printstart 1:prs
error: Please use both -printstart <phase_id> and -printstop <phase_id>
error: If it is only one phase/subphase/cyclephase you want reported
error: then the -printstart and -printstop options should be identical.
compilation failed while Loading SAC program, 1 error(s).

Proposed:

$ sac2c generic_error.sac -printstart 1:prs
Error: Please use both -printstart <phase_id> and -printstop <phase_id>
  If it is only one phase/subphase/cyclephase you want reported
  then the -printstart and -printstop options should be identical.
Compilation failed while Loading SAC program, 1 error(s).
Errors with line information Current:
$ sac2c overload_error.sac
./overload_error.sac 10 abort: Cannot overload functions of arity 0
compilation failed while Converting to static single assignment form.

Proposed:

$ sac2c overload_error.sac
./overload_error.sac 10 abort: 
  Cannot overload functions of arity 0
Compilation failed while Converting to static single assignment form.
Errors line and column information

Current:

$ sac2c syntax_error.sac
./syntax_error.sac:7:12: error:
=> token `}' expected, `f' token found
./syntax_error.sac:7:12: error:
=> type expected, `f' found
./syntax_error.sac:9:1: error:
=> function body or semicolon expected
abort: Failed to construct a syntax tree for `syntax_error.sac'
compilation failed while Loading SAC program, 3 error(s).

Proposed:

$ sac2c syntax_error.sac
./syntax_error.sac:7:12: error:
  token `}' expected, `f' token found
./syntax_error.sac:7:12: error:
  type expected, `f' found
./syntax_error.sac:9:1: error:
  function body or semicolon expected
Abort: Failed to construct a syntax tree for `syntax_error.sac'
Compilation failed while Loading SAC program, 3 error(s).

I am still unsure what to do about SAC optimization errors. For the purposes of easily detecting them, I'd like to give them a special header like optimization error. Other than that, I'm told that finding the location in the source code instead of generated code is a worth a thesis on its own, so we probably can't make those more kind to the users.

Edited Jan 19, 2022 by Michiel Verloop
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking