[Bug c/82354] semi-colon instead of comma in parameter list produces confusing diagnostics

manu at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Sep 28 21:38:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82354

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
For the location problem:

  if (pedantic && !current_scope->warned_forward_parm_decls)
    {
      pedwarn (input_location, OPT_Wpedantic,
               "ISO C forbids forward parameter declarations");
      current_scope->warned_forward_parm_decls = true;
    }

versus

          /* Check for forward decls that never got their actual decl.  */
          if (TREE_ASM_WRITTEN (decl))
            error_at (b->locus,
                      "parameter %q+D has just a forward declaration", decl);

by the way %+D overrides b->locus, so something is wrong above. I see quite a
few cases under c/.

At the time we warn, we don't know of this is a typo, we have to assume that
the code is correct (and perhaps give a warning). We only know that something
is wrong by the time we finish parsing all parameters. However, after the
error, we could assume that the forward declaration was an actual definition
(assume , instead of ;) to avoid the cascade of errors.

Perhaps it would be possible to delay the warning up to the point where we will
emit (or not) an error. Then, if there is an error, don't give a warning and
suggest ';'. If there is no error, give (or not) the warning and don't suggest
anything.


Besides, I still think that we should adopt the wording of clang and say:

"parameter forward declarations are a GNU extension"


More information about the Gcc-bugs mailing list