[cfe-dev] Unneeded declarations invalidation

Eli Friedman eli.friedman at gmail.com
Tue Jul 7 05:16:52 PDT 2009


On Tue, Jul 7, 2009 at 3:46 AM, Enea Zaffanella<zaffanella at cs.unipr.it> wrote:
> Index: include/clang/Basic/DiagnosticSemaKinds.td
> ===================================================================
> --- include/clang/Basic/DiagnosticSemaKinds.td  (revision 74831)
> +++ include/clang/Basic/DiagnosticSemaKinds.td  (working copy)
> @@ -1191,6 +1191,8 @@
>   "arithmetic on pointer to void type">;
>  def err_typecheck_decl_incomplete_type : Error<
>   "variable has incomplete type %0">;
> +def warn_typecheck_decl_incomplete_type : Warning<
> +  "variable has incomplete type %0">;

This should be an ExtWarn; it's generally the preferred classification
for issues which make the translation unit undefined at compile-time.
Also, it would be nice to explicitly point out the issue, more like
"tentative definition of variable with internal linkage has incomplete
type %0" (I actually don't particularly like that wording, but the
issue is a bit technical, so I'm not sure how to rephrase it.)

> +        // NOTE: code such as the following
> +        //     static struct s;
> +        //     struct s { int a; };
> +        // is accepted by gcc. Hence here we issue a warning instead of
> +        // an error and we do not invalidate the static declaration.
> +        (void) RequireCompleteType(IDecl->getLocation(), T,
> +
> diag::warn_typecheck_decl_incomplete_type);

LLVM style generally does not include explicit casts to void.


It's not ideal that we produce a warning and then an error, but it
doesn't really matter too much.

Does this patch react reasonably to multiple tentative definitions?
It looks like it should, but it's probably worth having a test for it.

Otherwise, it looks fine.

-Eli




More information about the cfe-dev mailing list