This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: `--syntax-only' after error


Another alternative implementation of this, if it's concluded
that we can't afford to lose errors in a fatal compilation:

1) Turn optimization level down to 0.  (This probably turns off
   "unused variable" warnings, but...)  That's trivial, and has
   a pretty high return, because optimization is the expensive
   part of many compilations anyway.  (Turn off profiling and
   the like at the same time.)
2) Not so trivial: turn off any remaining compilation stages
   in toplev that don't yield warnings/errors.  (Specifically,
   those that do the generation of the acutal assembler.)
   (Probably the code just below the comment:
     /* Now turn the rtl into assembler code.  */
   in toplev.c.)

This doesn't save as much as --syntax-only would, but it's a
viable intermediate position to leaving everything on.

(Don't count this as a vote for not doing --syntax-only after
an error; the reality is that you can never trust a compiler
to catch all errors after a syntax error anyway, so I don't see
the lossage as too significant.  I know others disagree.  I have
used compilers that appear to do this, and I never felt burdened
by the possible loss of a (subtle) error message or two.)

Thinking out loud... there are syntax errors (e.g. grammar) that
can cause the compiler to go crazy, and there are semantic errors
that make the program uncompilable, but which don't cascade
(e.g. undeclared variable).  Should they do different things?
(No opinion expressed, just a thought.)

Donn

-- 

===================================================
Donn Terry                  mailto:donn@interix.com
Softway Systems, Inc.        http://www.interix.com
2850 McClelland Dr, Ste. 1800   Ft.Collins CO 80525
Tel: +1-970-204-9900           Fax: +1-970-204-9951
===================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]