GCC: Report multiple occurrences of the "same" error

I’m sure GCC is trying to be helpful in reporting only the first occurrence of the “same” error - but I find it unhelpful. :frowning:

eg, if I make a typo in a symbol name, and that mistake has been repeated, most compilers will report an error on each occurrence - this makes it easy to go through all the errors, fix them, and then know that all those typos have been fixed.

But GCC just tells you about the first typo; so you fix that and think, “right, that’s all the errors fixed!” - but then you rebuild, and find the next one. :frowning:

No doubt GCC thinks it is trying to be helpful by not swamping you with loads of “duplicate” errors - but, as illustrated above, it is not helpful at all. :angry:

Is there a way to get GCC to report each and every occurrence?

Behold the power of OSS! I have the source code for the feature in question:

undeclared_variable (tree id)
  static bool already = false;
  struct c_scope *scope;

  if (current_function_decl == 0)
      error ("%qE undeclared here (not in a function)", id);
      scope = current_scope;
      error ("%qE undeclared (first use in this function)", id);

      if (!already)
          error ("(Each undeclared identifier is reported only once");
          error ("for each function it appears in.)");
          already = true;

      /* If we are parsing old-style parameter decls, current_function_decl
         will be nonnull but current_function_scope will be null.  */
      scope = current_function_scope ? current_function_scope : current_scope;
  bind (id, error_mark_node, scope, /*invisible=*/false, /*nested=*/false);

So, the answer is: No. There’s no option to change this behavior.
However, it would be trivial to remove the already = true; line and recompile.

EDIT: If you really don’t like the feature, you could supply a patch to the GCC developers that would allow for the feature to be disabled via command line argument. That way, others can benefit too.

I assume that OSS = “Open Source Software” ?


Hmm… not at all sure that this bit would classify as “trivial”…! :open_mouth:

Alternatively, do you know where would be the best place to post this as a request/suggestion to people better equipped than me to do it?


Follow Step 2 here: viewtopic.php?f=19&t=2133
Since you’re using Cygwin, some of the configure options will change. Run arm-elf-gcc -v so see which options your existing gcc was configured with.

I recommend posting your request to the “gcc” mailing list here: gcc.gnu.org/lists.html
If you’re interested in submitting a patch, look here: gcc.gnu.org/contribute.html#patches