[cfe-commits] [PATCH] Fix isThisDeclarationADefinition for extern following tentative.

Douglas Gregor dgregor at apple.com
Mon Dec 17 13:49:55 PST 2012


LGTM!

On Dec 15, 2012, at 3:50 PM, Rafael Ávila de Espíndola <rafael.espindola at gmail.com> wrote:

> An extern declaration following a tentative definition should not itself be
> considered a tentative definition.
> Fixes pr14614.
> ---
> lib/AST/Decl.cpp          | 2 +-
> test/Sema/extern-redecl.c | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
> index 538dcee..4e4bc0e 100644
> --- a/lib/AST/Decl.cpp
> +++ b/lib/AST/Decl.cpp
> @@ -1220,7 +1220,7 @@ VarDecl::DefinitionKind VarDecl::isThisDeclarationADefinition(
>        getStorageClassAsWritten() == SC_PrivateExtern) {
>     for (const VarDecl *PrevVar = getPreviousDecl();
>          PrevVar; PrevVar = PrevVar->getPreviousDecl()) {
> -      if (PrevVar->getLinkage() == InternalLinkage && PrevVar->hasInit())
> +      if (PrevVar->getLinkage() == InternalLinkage)
>         return DeclarationOnly;
>     }
>   }
> diff --git a/test/Sema/extern-redecl.c b/test/Sema/extern-redecl.c
> index c176725..ae4386e 100644
> --- a/test/Sema/extern-redecl.c
> +++ b/test/Sema/extern-redecl.c
> @@ -20,3 +20,5 @@ int PR10013(void) {
>   return PR10013_x; // expected-warning{{incompatible pointer to integer conversion}}
> }
> 
> +static int test1_a[]; // expected-warning {{tentative array definition assumed to have one element}}
> +extern int test1_a[];
> -- 
> 1.7.11.7
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list