<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 9, 2015 at 11:55 AM, Ben Langmuir via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> On Dec 9, 2015, at 11:07 AM, Ben Langmuir <<a href="mailto:blangmuir@apple.com">blangmuir@apple.com</a>> wrote:<br>
><br>
> Hey Richard,<br>
><br>
> This caused a new error for the following code:<br>
><br>
>    @import Foo.X; // declaration of ‘struct foo’ from Foo.Y is not visible yet, but the pcm is loaded.<br>
>    struct foo *bar; // declares ‘struct foo’<br>
>    @import Foo.Y; // also declares ‘struct foo’<br>
><br>
>    void useFoo(struct foo *x);  // error: reference to ‘foo’ is ambiguous<br>
><br>
> This seems to be specific to declaring the tag with an elaborated type specifier that is not just ‘struct foo;’.  Any idea what went wrong?  I’m trying to track this down and fix it.<br>
<br>
</span>It’s also specific to non-C++ language modes.  In C++ we seem to cheat and make a second lookup that has ForRedeclaration set (SemaDecl.cpp:12122) which then turns this into a use of the hidden declaration rather than creating a new declaration or redeclaration.  I call this “cheating” because the comments imply this second lookup is for diagnostic purposes, but it clearly has a semantic affect in this case.<br></blockquote><div><br></div><div>Well, this comes back to our handling of C structs and modules being a little incoherent. Suppose Foo.Y defines one 'struct foo', and we define a completely different 'struct foo':</div><div><br></div><div>// Foo.Y</div><div>struct foo { int n; };</div><div><br></div><div>// my.c</div><div>@import Foo.X;</div><div>struct foo *bar;</div><div>struct foo { double d; };</div><div>// Don't import Foo.Y</div><div><br></div><div>If this is not an error, then our declaration of 'struct foo' cannot be the same type as Foo.Y. The usual C rule for structs is that you can have multiple conflicting definitions in different TUs. Such declarations declare different types, but they're compatible types (and thus can be used interchangeably) if they're structurally equivalent.</div><div><br></div><div>I think implementing that rule for C is the right way to go here. Either that, or we extend C++'s ODR semantics to C modules, but given that the C standard gives us a completely reasonable rule here, it seems more appropriate to follow it.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I guess the reason this started failing after r252960 is because of this change:<br>
<span class="">> This also removes the prior special case for tag lookup, which made some cases<br>
> of this work, but also led to bizarre, bogus "must use 'struct' to refer to type<br>
> 'Foo' in this scope" diagnostics in C++.<br>
<br>
</span>We could do the for-redeclaration lookup outside of C++ too, which will fix this case,</blockquote><div><br></div><div>I don't think so: structs in C don't have linkage, so the for-redeclaration lookup won't find unimported structs (though it's possible that we get the linkage calculation for C structs wrong).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">but I’m not sure if this is the correct fix.<br>
<br>
Thoughts?<br>
<br>
Ben<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> Ben<br>
><br>
>> On Nov 12, 2015, at 2:19 PM, Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
>><br>
>> Author: rsmith<br>
>> Date: Thu Nov 12 16:19:45 2015<br>
>> New Revision: 252960<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=252960&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=252960&view=rev</a><br>
>> Log:<br>
>> [modules] Simplify and generalize the existing rule for finding hidden<br>
>> declarations in redeclaration lookup. A declaration is now visible to<br>
>> lookup if:<br>
>><br>
>> * It is visible (not in a module, or in an imported module), or<br>
>> * We're doing redeclaration lookup and it's externally-visible, or<br>
>> * We're doing typo correction and looking for unimported decls.<br>
>><br>
>> We now support multiple modules having different internal-linkage or no-linkage<br>
>> definitions of the same name for all entities, not just for functions,<br>
>> variables, and some typedefs. As previously, if multiple such entities are<br>
>> visible, any attempt to use them will result in an ambiguity error.<br>
>><br>
>> This patch fixes the linkage calculation for a number of entities where we<br>
>> previously didn't need to get it right (using-declarations, namespace aliases,<br>
>> and so on).  It also classifies enumerators as always having no linkage, which<br>
>> is a slight deviation from the C++ standard's definition, but not an observable<br>
>> change outside modules (this change is being discussed on the -core reflector<br>
>> currently).<br>
>><br>
>> This also removes the prior special case for tag lookup, which made some cases<br>
>> of this work, but also led to bizarre, bogus "must use 'struct' to refer to type<br>
>> 'Foo' in this scope" diagnostics in C++.<br>
>><br>
>> Added:<br>
>>   cfe/trunk/test/Modules/Inputs/no-linkage/<br>
>>   cfe/trunk/test/Modules/Inputs/no-linkage/decls.h<br>
>>   cfe/trunk/test/Modules/Inputs/no-linkage/empty.h<br>
>>   cfe/trunk/test/Modules/Inputs/no-linkage/module.modulemap<br>
>>   cfe/trunk/test/Modules/no-linkage.cpp<br>
>> Modified:<br>
>>   cfe/trunk/include/clang/Sema/Lookup.h<br>
>>   cfe/trunk/lib/AST/Decl.cpp<br>
>>   cfe/trunk/lib/Sema/SemaDecl.cpp<br>
>>   cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
>>   cfe/trunk/test/Index/linkage.c<br>
>>   cfe/trunk/test/Index/usrs.m<br>
>>   cfe/trunk/test/Modules/decldef.m<br>
>>   cfe/trunk/test/Modules/merge-enumerators.cpp<br>
>>   cfe/trunk/test/Modules/module-private.cpp<br>
>>   cfe/trunk/test/Modules/submodule-visibility-cycles.cpp<br>
>>   cfe/trunk/test/Modules/submodules-merge-defs.cpp<br>
>><br>
>> Modified: cfe/trunk/include/clang/Sema/Lookup.h<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=252960&r1=252959&r2=252960&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=252960&r1=252959&r2=252960&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/include/clang/Sema/Lookup.h (original)<br>
>> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Nov 12 16:19:45 2015<br>
>> @@ -139,8 +139,7 @@ public:<br>
>>      Redecl(Redecl != Sema::NotForRedeclaration),<br>
>>      HideTags(true),<br>
>>      Diagnose(Redecl == Sema::NotForRedeclaration),<br>
>> -      AllowHidden(Redecl == Sema::ForRedeclaration),<br>
>> -      AllowHiddenInternal(AllowHidden),<br>
>> +      AllowHidden(false),<br>
>>      Shadowed(false)<br>
>>  {<br>
>>    configure();<br>
>> @@ -162,8 +161,7 @@ public:<br>
>>      Redecl(Redecl != Sema::NotForRedeclaration),<br>
>>      HideTags(true),<br>
>>      Diagnose(Redecl == Sema::NotForRedeclaration),<br>
>> -      AllowHidden(Redecl == Sema::ForRedeclaration),<br>
>> -      AllowHiddenInternal(AllowHidden),<br>
>> +      AllowHidden(false),<br>
>>      Shadowed(false)<br>
>>  {<br>
>>    configure();<br>
>> @@ -184,7 +182,6 @@ public:<br>
>>      HideTags(Other.HideTags),<br>
>>      Diagnose(false),<br>
>>      AllowHidden(Other.AllowHidden),<br>
>> -      AllowHiddenInternal(Other.AllowHiddenInternal),<br>
>>      Shadowed(false)<br>
>>  {}<br>
>><br>
>> @@ -226,27 +223,16 @@ public:<br>
>>  /// \brief Specify whether hidden declarations are visible, e.g.,<br>
>>  /// for recovery reasons.<br>
>>  void setAllowHidden(bool AH) {<br>
>> -    AllowHiddenInternal = AllowHidden = AH;<br>
>> -  }<br>
>> -<br>
>> -  /// \brief Specify whether hidden internal declarations are visible.<br>
>> -  void setAllowHiddenInternal(bool AHI) {<br>
>> -    AllowHiddenInternal = AHI;<br>
>> +    AllowHidden = AH;<br>
>>  }<br>
>><br>
>>  /// \brief Determine whether this lookup is permitted to see hidden<br>
>>  /// declarations, such as those in modules that have not yet been imported.<br>
>>  bool isHiddenDeclarationVisible(NamedDecl *ND) const {<br>
>> -    // If a using-shadow declaration is hidden, it's never visible, not<br>
>> -    // even to redeclaration lookup.<br>
>> -    // FIXME: Should this apply to typedefs and namespace aliases too?<br>
>> -    if (isa<UsingShadowDecl>(ND) && LookupKind != Sema::LookupUsingDeclName)<br>
>> -      return false;<br>
>> -    return (AllowHidden &&<br>
>> -            (AllowHiddenInternal || ND->isExternallyVisible())) ||<br>
>> -           LookupKind == Sema::LookupTagName;<br>
>> +    return AllowHidden ||<br>
>> +           (isForRedeclaration() && ND->isExternallyVisible());<br>
>>  }<br>
>> -<br>
>> +<br>
>>  /// Sets whether tag declarations should be hidden by non-tag<br>
>>  /// declarations during resolution.  The default is true.<br>
>>  void setHideTags(bool Hide) {<br>
>> @@ -317,7 +303,8 @@ public:<br>
>>    if (!D->isInIdentifierNamespace(IDNS))<br>
>>      return nullptr;<br>
>><br>
>> -    if (isHiddenDeclarationVisible(D) || isVisible(getSema(), D))<br>
>> +    if (!D->isHidden() || isHiddenDeclarationVisible(D) ||<br>
>> +        isVisibleSlow(getSema(), D))<br>
>>      return D;<br>
>><br>
>>    return getAcceptableDeclSlow(D);<br>
>> @@ -526,7 +513,6 @@ public:<br>
>>  /// \brief Change this lookup's redeclaration kind.<br>
>>  void setRedeclarationKind(Sema::RedeclarationKind RK) {<br>
>>    Redecl = RK;<br>
>> -    AllowHiddenInternal = AllowHidden = (RK == Sema::ForRedeclaration);<br>
>>    configure();<br>
>>  }<br>
>><br>
>> @@ -698,9 +684,6 @@ private:<br>
>>  /// \brief True if we should allow hidden declarations to be 'visible'.<br>
>>  bool AllowHidden;<br>
>><br>
>> -  /// \brief True if we should allow hidden internal declarations to be visible.<br>
>> -  bool AllowHiddenInternal;<br>
>> -<br>
>>  /// \brief True if the found declarations were shadowed by some other<br>
>>  /// declaration that we skipped. This only happens when \c LookupKind<br>
>>  /// is \c LookupRedeclarationWithLinkage.<br>
>><br>
>> Modified: cfe/trunk/lib/AST/Decl.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=252960&r1=252959&r2=252960&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=252960&r1=252959&r2=252960&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/lib/AST/Decl.cpp (original)<br>
>> +++ cfe/trunk/lib/AST/Decl.cpp Thu Nov 12 16:19:45 2015<br>
>> @@ -635,6 +635,8 @@ static LinkageInfo getLVForNamespaceScop<br>
>>  if (D->isInAnonymousNamespace()) {<br>
>>    const auto *Var = dyn_cast<VarDecl>(D);<br>
>>    const auto *Func = dyn_cast<FunctionDecl>(D);<br>
>> +    // FIXME: In C++11 onwards, anonymous namespaces should give decls<br>
>> +    // within them internal linkage, not unique external linkage.<br>
>>    if ((!Var || !isFirstInExternCContext(Var)) &&<br>
>>        (!Func || !isFirstInExternCContext(Func)))<br>
>>      return LinkageInfo::uniqueExternal();<br>
>> @@ -821,10 +823,14 @@ static LinkageInfo getLVForNamespaceScop<br>
>>  } else if (isa<ObjCInterfaceDecl>(D)) {<br>
>>    // fallout<br>
>><br>
>> +  } else if (auto *TD = dyn_cast<TypedefNameDecl>(D)) {<br>
>> +    // A typedef declaration has linkage if it gives a type a name for<br>
>> +    // linkage purposes.<br>
>> +    if (!TD->getAnonDeclWithTypedefName(/*AnyRedecl*/true))<br>
>> +      return LinkageInfo::none();<br>
>> +<br>
>>  // Everything not covered here has no linkage.<br>
>>  } else {<br>
>> -    // FIXME: A typedef declaration has linkage if it gives a type a name for<br>
>> -    // linkage purposes.<br>
>>    return LinkageInfo::none();<br>
>>  }<br>
>><br>
>> @@ -1226,8 +1232,32 @@ static LinkageInfo computeLVForDecl(cons<br>
>>  switch (D->getKind()) {<br>
>>    default:<br>
>>      break;<br>
>> +<br>
>> +    // Per C++ [basic.link]p2, only the names of objects, references,<br>
>> +    // functions, types, templates, namespaces, and values ever have linkage.<br>
>> +    //<br>
>> +    // Note that the name of a typedef, namespace alias, using declaration,<br>
>> +    // and so on are not the name of the corresponding type, namespace, or<br>
>> +    // declaration, so they do *not* have linkage.<br>
>> +    case Decl::EnumConstant: // FIXME: This has linkage, but that's dumb.<br>
>> +    case Decl::ImplicitParam:<br>
>> +    case Decl::Label:<br>
>> +    case Decl::NamespaceAlias:<br>
>>    case Decl::ParmVar:<br>
>> +    case Decl::Using:<br>
>> +    case Decl::UsingShadow:<br>
>> +    case Decl::UsingDirective:<br>
>>      return LinkageInfo::none();<br>
>> +<br>
>> +    case Decl::Typedef:<br>
>> +    case Decl::TypeAlias:<br>
>> +      // A typedef declaration has linkage if it gives a type a name for<br>
>> +      // linkage purposes.<br>
>> +      if (!cast<TypedefNameDecl>(D)<br>
>> +               ->getAnonDeclWithTypedefName(/*AnyRedecl*/true))<br>
>> +        return LinkageInfo::none();<br>
>> +      break;<br>
>> +<br>
>>    case Decl::TemplateTemplateParm: // count these as external<br>
>>    case Decl::NonTypeTemplateParm:<br>
>>    case Decl::ObjCAtDefsField:<br>
>><br>
>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=252960&r1=252959&r2=252960&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=252960&r1=252959&r2=252960&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Nov 12 16:19:45 2015<br>
>> @@ -4819,12 +4819,6 @@ NamedDecl *Sema::HandleDeclarator(Scope<br>
>>  LookupResult Previous(*this, NameInfo, LookupOrdinaryName,<br>
>>                        ForRedeclaration);<br>
>><br>
>> -  // If we're hiding internal-linkage symbols in modules from redeclaration<br>
>> -  // lookup, let name lookup know.<br>
>> -  if ((getLangOpts().Modules || getLangOpts().ModulesLocalVisibility) &&<br>
>> -      D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef)<br>
>> -    Previous.setAllowHiddenInternal(false);<br>
>> -<br>
>>  // See if this is a redefinition of a variable in the same scope.<br>
>>  if (!D.getCXXScopeSpec().isSet()) {<br>
>>    bool IsLinkageLookup = false;<br>
>><br>
>> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=252960&r1=252959&r2=252960&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=252960&r1=252959&r2=252960&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)<br>
>> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Nov 12 16:19:45 2015<br>
>> @@ -7206,23 +7206,13 @@ Decl *Sema::ActOnStartNamespaceDef(Scope<br>
>>    //   treated as an original-namespace-name.<br>
>>    //<br>
>>    // Since namespace names are unique in their scope, and we don't<br>
>> -    // look through using directives, just look for any ordinary names.<br>
>> -<br>
>> -    const unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_Member |<br>
>> -    Decl::IDNS_Type | Decl::IDNS_Using | Decl::IDNS_Tag |<br>
>> -    Decl::IDNS_Namespace;<br>
>> -    NamedDecl *PrevDecl = nullptr;<br>
>> -    DeclContext::lookup_result R = CurContext->getRedeclContext()->lookup(II);<br>
>> -    for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E;<br>
>> -         ++I) {<br>
>> -      if ((*I)->getIdentifierNamespace() & IDNS) {<br>
>> -        PrevDecl = *I;<br>
>> -        break;<br>
>> -      }<br>
>> -    }<br>
>> -<br>
>> +    // look through using directives, just look for any ordinary names<br>
>> +    // as if by qualified name lookup.<br>
>> +    LookupResult R(*this, II, IdentLoc, LookupOrdinaryName, ForRedeclaration);<br>
>> +    LookupQualifiedName(R, CurContext->getRedeclContext());<br>
>> +    NamedDecl *PrevDecl = R.getAsSingle<NamedDecl>();<br>
>>    PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);<br>
>> -<br>
>> +<br>
>>    if (PrevNS) {<br>
>>      // This is an extended namespace definition.<br>
>>      if (IsInline != PrevNS->isInline())<br>
>><br>
>> Modified: cfe/trunk/test/Index/linkage.c<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/linkage.c?rev=252960&r1=252959&r2=252960&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/linkage.c?rev=252960&r1=252959&r2=252960&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Index/linkage.c (original)<br>
>> +++ cfe/trunk/test/Index/linkage.c Thu Nov 12 16:19:45 2015<br>
>> @@ -20,7 +20,7 @@ void f16(void) {<br>
>><br>
>><br>
>> // CHECK: EnumDecl=Baz:3:6 (Definition)linkage=External<br>
>> -// CHECK: EnumConstantDecl=Qux:3:12 (Definition)linkage=External<br>
>> +// CHECK: EnumConstantDecl=Qux:3:12 (Definition)linkage=NoLinkage<br>
>> // CHECK: VarDecl=x:4:5linkage=External<br>
>> // CHECK: FunctionDecl=foo:5:6linkage=External<br>
>> // CHECK: VarDecl=w:6:12linkage=Internal<br>
>><br>
>> Modified: cfe/trunk/test/Index/usrs.m<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/usrs.m?rev=252960&r1=252959&r2=252960&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/usrs.m?rev=252960&r1=252959&r2=252960&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Index/usrs.m (original)<br>
>> +++ cfe/trunk/test/Index/usrs.m Thu Nov 12 16:19:45 2015<br>
>> @@ -119,7 +119,7 @@ int test_multi_declaration(void) {<br>
>> // CHECK: usrs.m c:@SA@MyStruct Extent=[15:9 - 18:2]<br>
>> // CHECK: usrs.m c:@SA@MyStruct@FI@wa Extent=[16:3 - 16:9]<br>
>> // CHECK: usrs.m c:@SA@MyStruct@FI@moo Extent=[17:3 - 17:10]<br>
>> -// CHECK: usrs.m c:usrs.m@T@MyStruct Extent=[15:1 - 18:11]<br>
>> +// CHECK: usrs.m c:@T@MyStruct Extent=[15:1 - 18:11]<br>
>> // CHECK: usrs.m c:@E@Pizza Extent=[20:1 - 23:2]<br>
>> // CHECK: usrs.m c:@E@Pizza@CHEESE Extent=[21:3 - 21:9]<br>
>> // CHECK: usrs.m c:@E@Pizza@MUSHROOMS Extent=[22:3 - 22:12]<br>
>><br>
>> Added: cfe/trunk/test/Modules/Inputs/no-linkage/decls.h<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/no-linkage/decls.h?rev=252960&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/no-linkage/decls.h?rev=252960&view=auto</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Modules/Inputs/no-linkage/decls.h (added)<br>
>> +++ cfe/trunk/test/Modules/Inputs/no-linkage/decls.h Thu Nov 12 16:19:45 2015<br>
>> @@ -0,0 +1,6 @@<br>
>> +namespace RealNS { int UsingDecl; }<br>
>> +namespace NS = RealNS;<br>
>> +typedef int Typedef;<br>
>> +using AliasDecl = int;<br>
>> +enum Enum { Enumerator };<br>
>> +using RealNS::UsingDecl;<br>
>><br>
>> Added: cfe/trunk/test/Modules/Inputs/no-linkage/empty.h<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/no-linkage/empty.h?rev=252960&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/no-linkage/empty.h?rev=252960&view=auto</a><br>
>> ==============================================================================<br>
>>   (empty)<br>
>><br>
>> Added: cfe/trunk/test/Modules/Inputs/no-linkage/module.modulemap<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/no-linkage/module.modulemap?rev=252960&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/no-linkage/module.modulemap?rev=252960&view=auto</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Modules/Inputs/no-linkage/module.modulemap (added)<br>
>> +++ cfe/trunk/test/Modules/Inputs/no-linkage/module.modulemap Thu Nov 12 16:19:45 2015<br>
>> @@ -0,0 +1 @@<br>
>> +module M { module E { header "empty.h" } module D { header "decls.h" } }<br>
>><br>
>> Modified: cfe/trunk/test/Modules/decldef.m<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/decldef.m?rev=252960&r1=252959&r2=252960&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/decldef.m?rev=252960&r1=252959&r2=252960&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Modules/decldef.m (original)<br>
>> +++ cfe/trunk/test/Modules/decldef.m Thu Nov 12 16:19:45 2015<br>
>> @@ -11,7 +11,13 @@ Def *def;<br>
>> #ifdef USE_EARLY<br>
>> A *a1; // expected-error{{declaration of 'A' must be imported from module 'decldef.Def' before it is required}}<br>
>> #endif<br>
>> -B *b1; // expected-error{{must use 'struct' tag to refer to type 'B'}}<br>
>> +B *b1;<br>
>> +#ifdef USE_EARLY<br>
>> +// expected-error@-2{{must use 'struct' tag to refer to type 'B'}}<br>
>> +#else<br>
>> +// expected-error@-4{{declaration of 'B' must be imported from module 'decldef.Decl' before it is required}}<br>
>> +// expected-note@Inputs/decl.h:2 {{previous}}<br>
>> +#endif<br>
>> @import decldef.Decl;<br>
>><br>
>> A *a2;<br>
>><br>
>> Modified: cfe/trunk/test/Modules/merge-enumerators.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-enumerators.cpp?rev=252960&r1=252959&r2=252960&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-enumerators.cpp?rev=252960&r1=252959&r2=252960&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Modules/merge-enumerators.cpp (original)<br>
>> +++ cfe/trunk/test/Modules/merge-enumerators.cpp Thu Nov 12 16:19:45 2015<br>
>> @@ -16,11 +16,13 @@<br>
>><br>
>> #ifdef MERGE_LATE<br>
>> namespace N {<br>
>> -  // FIXME: Should we accept this and reject the usage below due to ambiguity instead?<br>
>> -  enum { A } a; // expected-error {{redefinition of enumerator 'A'}}<br>
>> -  // expected-note@a.h:1 {{here}} (from module B.b)<br>
>> +  enum { A } a; // expected-note {{candidate}}<br>
>> +  // expected-note@a.h:1 {{candidate}} (from module B.b)<br>
>> }<br>
>> #include "a.h"<br>
>> #endif<br>
>><br>
>> N::E e = N::A;<br>
>> +#ifdef MERGE_LATE<br>
>> +// expected-error@-2 {{ambiguous}}<br>
>> +#endif<br>
>><br>
>> Modified: cfe/trunk/test/Modules/module-private.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-private.cpp?rev=252960&r1=252959&r2=252960&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-private.cpp?rev=252960&r1=252959&r2=252960&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Modules/module-private.cpp (original)<br>
>> +++ cfe/trunk/test/Modules/module-private.cpp Thu Nov 12 16:19:45 2015<br>
>> @@ -12,11 +12,7 @@ void test() {<br>
>> }<br>
>><br>
>> int test_broken() {<br>
>> -  HiddenStruct hidden; // \<br>
>> -  // expected-error{{must use 'struct' tag to refer to type 'HiddenStruct' in this scope}} \<br>
>> -  // expected-error{{definition of 'HiddenStruct' must be imported}}<br>
>> -  // expected-note@Inputs/module_private_left.h:3 {{previous definition is here}}<br>
>> -<br>
>> +  HiddenStruct hidden; // expected-error{{unknown type name 'HiddenStruct'}}<br>
>>  Integer i; // expected-error{{unknown type name 'Integer'}}<br>
>><br>
>>  int *ip = 0;<br>
>><br>
>> Added: cfe/trunk/test/Modules/no-linkage.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/no-linkage.cpp?rev=252960&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/no-linkage.cpp?rev=252960&view=auto</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Modules/no-linkage.cpp (added)<br>
>> +++ cfe/trunk/test/Modules/no-linkage.cpp Thu Nov 12 16:19:45 2015<br>
>> @@ -0,0 +1,35 @@<br>
>> +// RUN: rm -rf %t<br>
>> +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodules-local-submodule-visibility -I%S/Inputs/no-linkage -fmodule-map-file=%S/Inputs/no-linkage/module.modulemap %s -verify<br>
>> +<br>
>> +#include "empty.h"<br>
>> +<br>
>> +namespace NS { int n; } // expected-note {{candidate}}<br>
>> +struct Typedef { int n; }; // expected-note {{candidate}}<br>
>> +int AliasDecl; // expected-note {{candidate}}<br>
>> +enum AlsoAnEnum { Enumerator }; // expected-note {{candidate}}<br>
>> +int UsingDecl; // expected-note {{candidate}}<br>
>> +<br>
>> +// expected-note@decls.h:2 {{candidate}}<br>
>> +// expected-note@decls.h:3 {{candidate}}<br>
>> +// expected-note@decls.h:4 {{candidate}}<br>
>> +// expected-note@decls.h:5 {{candidate}}<br>
>> +// expected-note@decls.h:6 {{candidate}}<br>
>> +<br>
>> +void use(int);<br>
>> +void use_things() {<br>
>> +  use(Typedef().n);<br>
>> +  use(NS::n);<br>
>> +  use(AliasDecl);<br>
>> +  use(Enumerator);<br>
>> +  use(UsingDecl);<br>
>> +}<br>
>> +<br>
>> +#include "decls.h"<br>
>> +<br>
>> +void use_things_again() {<br>
>> +  use(Typedef().n); // expected-error {{ambiguous}}<br>
>> +  use(NS::n); // expected-error {{ambiguous}} expected-error{{'NS' is not a class, namespace, or enumeration}}<br>
>> +  use(AliasDecl); // expected-error {{ambiguous}}<br>
>> +  use(Enumerator); // expected-error {{ambiguous}}<br>
>> +  use(UsingDecl); // expected-error {{ambiguous}}<br>
>> +}<br>
>><br>
>> Modified: cfe/trunk/test/Modules/submodule-visibility-cycles.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/submodule-visibility-cycles.cpp?rev=252960&r1=252959&r2=252960&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/submodule-visibility-cycles.cpp?rev=252960&r1=252959&r2=252960&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Modules/submodule-visibility-cycles.cpp (original)<br>
>> +++ cfe/trunk/test/Modules/submodule-visibility-cycles.cpp Thu Nov 12 16:19:45 2015<br>
>> @@ -3,7 +3,7 @@<br>
>><br>
>> #include "cycle1.h"<br>
>> C1 c1;<br>
>> -C2 c2; // expected-error {{must be imported}} expected-error {{}}<br>
>> +C2 c2; // expected-error {{must be imported}}<br>
>> // expected-note@cycle2.h:6 {{here}}<br>
>><br>
>> #include "cycle2.h"<br>
>><br>
>> Modified: cfe/trunk/test/Modules/submodules-merge-defs.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/submodules-merge-defs.cpp?rev=252960&r1=252959&r2=252960&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/submodules-merge-defs.cpp?rev=252960&r1=252959&r2=252960&view=diff</a><br>
>> ==============================================================================<br>
>> --- cfe/trunk/test/Modules/submodules-merge-defs.cpp (original)<br>
>> +++ cfe/trunk/test/Modules/submodules-merge-defs.cpp Thu Nov 12 16:19:45 2015<br>
>> @@ -12,7 +12,7 @@<br>
>> #include "indirect.h"<br>
>> #endif<br>
>><br>
>> -A pre_a; // expected-error {{must use 'struct'}}<br>
>> +A pre_a;<br>
>> #ifdef IMPORT_USE_2<br>
>> // expected-error-re@-2 {{must be imported from one of {{.*}}stuff.use{{.*}}stuff.use-2}}<br>
>> #elif EARLY_INDIRECT_INCLUDE<br>
>> @@ -21,29 +21,28 @@ A pre_a; // expected-error {{must use 's<br>
>> // expected-error@-6 {{must be imported from module 'stuff.use'}}<br>
>> #endif<br>
>> // expected-note@defs.h:1 +{{here}}<br>
>> +extern class A pre_a2;<br>
>> +int pre_use_a = use_a(pre_a2); // expected-error {{'A' must be imported}} expected-error {{'use_a' must be imported}}<br>
>> // expected-note@defs.h:2 +{{here}}<br>
>> -int pre_use_a = use_a(pre_a); // expected-error {{'A' must be imported}} expected-error {{'use_a' must be imported}}<br>
>><br>
>> B::Inner2 pre_bi; // expected-error +{{must be imported}}<br>
>> // expected-note@defs.h:4 +{{here}}<br>
>> // expected-note@defs.h:17 +{{here}}<br>
>> -void pre_bfi(B b) { // expected-error {{must use 'class'}} expected-error +{{must be imported}}<br>
>> -  b.f<int>(); // expected-error +{{must be imported}} expected-error +{{}}<br>
>> -  // expected-note@defs.h:19 +{{here}}<br>
>> +void pre_bfi(B b) { // expected-error +{{must be imported}}<br>
>> +  b.f<int>(); // expected-error +{{}}<br>
>> }<br>
>><br>
>> C_Base<1> pre_cb1; // expected-error +{{must be imported}}<br>
>> // expected-note@defs.h:23 +{{here}}<br>
>> -C1 pre_c1; // expected-error +{{must be imported}} expected-error {{must use 'struct'}}<br>
>> +C1 pre_c1; // expected-error +{{must be imported}}<br>
>> // expected-note@defs.h:25 +{{here}}<br>
>> -C2 pre_c2; // expected-error +{{must be imported}} expected-error {{must use 'struct'}}<br>
>> +C2 pre_c2; // expected-error +{{must be imported}}<br>
>> // expected-note@defs.h:26 +{{here}}<br>
>><br>
>> D::X pre_dx; // expected-error +{{must be imported}}<br>
>> // expected-note@defs.h:28 +{{here}}<br>
>> // expected-note@defs.h:29 +{{here}}<br>
>> -// FIXME: We should warn that use_dx is being used without being imported.<br>
>> -int pre_use_dx = use_dx(pre_dx);<br>
>> +int pre_use_dx = use_dx(pre_dx); // ignored; pre_dx is invalid<br>
>><br>
>> int pre_e = E(0); // expected-error {{must be imported}}<br>
>> // expected-note@defs.h:32 +{{here}}<br>
>> @@ -69,8 +68,9 @@ J<> pre_j; // expected-error {{declarati<br>
>> #endif<br>
>> // expected-note@defs.h:58 +{{here}}<br>
>><br>
>> -ScopedEnum pre_scopedenum; // expected-error {{must be imported}} expected-error {{must use 'enum'}}<br>
>> -// expected-note@defs.h:106 {{here}}<br>
>> +ScopedEnum pre_scopedenum; // expected-error {{must be imported}}<br>
>> +// expected-note@defs.h:105 0-1{{here}}<br>
>> +// expected-note@defs.h:106 0-1{{here}}<br>
>> enum ScopedEnum : int;<br>
>> ScopedEnum pre_scopedenum_declared; // ok<br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
><br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>