r255377 - Reapply "[Modules] Fix regression when an elaborated-type-specifier mentions a hidden tag"

Sean Silva via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 11 17:28:15 PST 2015


On Fri, Dec 11, 2015 at 2:05 PM, Ben Langmuir via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: benlangmuir
> Date: Fri Dec 11 16:05:13 2015
> New Revision: 255377
>
> URL: http://llvm.org/viewvc/llvm-project?rev=255377&view=rev
> Log:
> Reapply "[Modules] Fix regression when an elaborated-type-specifier
> mentions a hidden tag"
>
> Now not trying to use a C++ lookup mechanism in C (d'oh).  Unqualified
> lookup is actually fine for this case in C.
>
> Added:
>     cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h
>     cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m
> Modified:
>     cfe/trunk/lib/Sema/SemaDecl.cpp
>     cfe/trunk/test/Modules/Inputs/module.map
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=255377&r1=255376&r2=255377&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Dec 11 16:05:13 2015
> @@ -12136,9 +12136,16 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
>
>      // In C++, we need to do a redeclaration lookup to properly
>      // diagnose some problems.
> +    // FIXME: redeclaration lookup is also used (with and without C++) to
> find a
> +    // hidden declaration so that we don't get ambiguity errors when
> using a
> +    // type declared by an elaborated-type-specifier.  In C that is not
> correct
> +    // and we should instead merge compatible types found by lookup.
>      if (getLangOpts().CPlusPlus) {
>        Previous.setRedeclarationKind(ForRedeclaration);
>        LookupQualifiedName(Previous, SearchDC);
> +    } else {
> +      Previous.setRedeclarationKind(ForRedeclaration);
> +      LookupName(Previous, S);
>

Can we move the comment inside the "else" to make it clear that the `else`
code is what the FIXME is relevant to?

-- Sean Silva


>      }
>    }
>
>
> Added: cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h?rev=255377&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h (added)
> +++ cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h Fri Dec 11
> 16:05:13 2015
> @@ -0,0 +1,3 @@
> +struct S1;
> +struct S2 { int x; };
> +struct S3 { int x; };
>
> Modified: cfe/trunk/test/Modules/Inputs/module.map
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=255377&r1=255376&r2=255377&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/module.map (original)
> +++ cfe/trunk/test/Modules/Inputs/module.map Fri Dec 11 16:05:13 2015
> @@ -386,3 +386,10 @@ module TypedefTag {
>      header "typedef-tag-hidden.h"
>    }
>  }
> +
> +module ElaboratedTypeStructs {
> +  module Empty {}
> +  module Structs {
> +    header "elaborated-type-structs.h"
> +  }
> +}
>
> Added:
> cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m?rev=255377&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m
> (added)
> +++ cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m
> Fri Dec 11 16:05:13 2015
> @@ -0,0 +1,18 @@
> +// RUN: rm -rf %t
> +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps
> -fmodules-cache-path=%t -I %S/Inputs %s -verify
> +
> + at import ElaboratedTypeStructs.Empty; // The structs are now hidden.
> +struct S1 *x;
> +struct S2 *y;
> +// FIXME: compatible definition should not be an error.
> +struct S2 { int x; }; // expected-error {{redefinition}}
> +struct S3 *z;
> +// Incompatible definition.
> +struct S3 { float y; }; // expected-error {{redefinition}}
> +// expected-note at elaborated-type-structs.h:* 2 {{previous definition is
> here}}
> +
> + at import ElaboratedTypeStructs.Structs;
> +
> +void useS1(struct S1 *x);
> +void useS2(struct S2 *x);
> +void useS2(struct S2 *x);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151211/e4268c3a/attachment.html>


More information about the cfe-commits mailing list