<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 11, 2015 at 2:05 PM, 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">Author: benlangmuir<br>
Date: Fri Dec 11 16:05:13 2015<br>
New Revision: 255377<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=255377&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=255377&view=rev</a><br>
Log:<br>
Reapply "[Modules] Fix regression when an elaborated-type-specifier mentions a hidden tag"<br>
<br>
Now not trying to use a C++ lookup mechanism in C (d'oh).  Unqualified<br>
lookup is actually fine for this case in C.<br>
<br>
Added:<br>
    cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h<br>
    cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaDecl.cpp<br>
    cfe/trunk/test/Modules/Inputs/module.map<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=255377&r1=255376&r2=255377&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=255377&r1=255376&r2=255377&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Dec 11 16:05:13 2015<br>
@@ -12136,9 +12136,16 @@ Decl *Sema::ActOnTag(Scope *S, unsigned<br>
<br>
     // In C++, we need to do a redeclaration lookup to properly<br>
     // diagnose some problems.<br>
+    // FIXME: redeclaration lookup is also used (with and without C++) to find a<br>
+    // hidden declaration so that we don't get ambiguity errors when using a<br>
+    // type declared by an elaborated-type-specifier.  In C that is not correct<br>
+    // and we should instead merge compatible types found by lookup.<br>
     if (getLangOpts().CPlusPlus) {<br>
       Previous.setRedeclarationKind(ForRedeclaration);<br>
       LookupQualifiedName(Previous, SearchDC);<br>
+    } else {<br>
+      Previous.setRedeclarationKind(ForRedeclaration);<br>
+      LookupName(Previous, S);<br></blockquote><div><br></div><div>Can we move the comment inside the "else" to make it clear that the `else` code is what the FIXME is relevant to?</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
     }<br>
   }<br>
<br>
<br>
Added: cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h?rev=255377&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h?rev=255377&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h (added)<br>
+++ cfe/trunk/test/Modules/Inputs/elaborated-type-structs.h Fri Dec 11 16:05:13 2015<br>
@@ -0,0 +1,3 @@<br>
+struct S1;<br>
+struct S2 { int x; };<br>
+struct S3 { int x; };<br>
<br>
Modified: cfe/trunk/test/Modules/Inputs/module.map<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=255377&r1=255376&r2=255377&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=255377&r1=255376&r2=255377&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/Inputs/module.map (original)<br>
+++ cfe/trunk/test/Modules/Inputs/module.map Fri Dec 11 16:05:13 2015<br>
@@ -386,3 +386,10 @@ module TypedefTag {<br>
     header "typedef-tag-hidden.h"<br>
   }<br>
 }<br>
+<br>
+module ElaboratedTypeStructs {<br>
+  module Empty {}<br>
+  module Structs {<br>
+    header "elaborated-type-structs.h"<br>
+  }<br>
+}<br>
<br>
Added: cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m?rev=255377&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m?rev=255377&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m (added)<br>
+++ cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m Fri Dec 11 16:05:13 2015<br>
@@ -0,0 +1,18 @@<br>
+// RUN: rm -rf %t<br>
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify<br>
+<br>
+@import ElaboratedTypeStructs.Empty; // The structs are now hidden.<br>
+struct S1 *x;<br>
+struct S2 *y;<br>
+// FIXME: compatible definition should not be an error.<br>
+struct S2 { int x; }; // expected-error {{redefinition}}<br>
+struct S3 *z;<br>
+// Incompatible definition.<br>
+struct S3 { float y; }; // expected-error {{redefinition}}<br>
+// expected-note@elaborated-type-structs.h:* 2 {{previous definition is here}}<br>
+<br>
+@import ElaboratedTypeStructs.Structs;<br>
+<br>
+void useS1(struct S1 *x);<br>
+void useS2(struct S2 *x);<br>
+void useS2(struct S2 *x);<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>
</blockquote></div><br></div></div>