<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>The spec seems to define completeness by the closing brace...</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Times; "><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Times; ">6.7.2.3p3 All declarations of structure, union, or enumerated types that have the same scope and<span style="font: 12.0px Helvetica"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Times; ">use the same tag declare the same type. The type is incomplete<span style="font: 9.0px Times">109)</span><span style="font: 12.0px Helvetica"> </span>until the closing brace<span style="font: 12.0px Helvetica"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Times; ">of the list deļ¬ning the content, and complete thereafter.<span style="font: 12.0px Helvetica"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Times; "><font class="Apple-style-span" face="Helvetica"><br class="webkit-block-placeholder"></font></div>
<div><div>If so, changing the predicate doesn't sound correct (though it makes sense to me conceptually).</div><div><br class="webkit-block-placeholder"></div><div>snaroff</div><div><br class="webkit-block-placeholder"></div><div>On Feb 10, 2008, at 8:07 PM, Steve Naroff wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 10, 2008, at 7:13 PM, Ted Kremenek wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 10, 2008, at 6:35 PM, Steve Naroff wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Folks,<br><br>Do you think it makes sense for Type::isIncompleteType() to return  <br>true when the Tag definition is invalid?</blockquote><div><br class="webkit-block-placeholder"></div><div>I guess so.  From the standard (<span class="Apple-style-span" style="font-family: Times; font-weight: bold; ">6.2.5):</span></div><div><br class="webkit-block-placeholder"></div><div><div>"... incomplete types (types that describe objects but lack information needed to determine their sizes). "</div> </div><div><br></div><div>I guess it depends on what clients expect.  Another way to look at this is that a bad tag definition doesn't really type check at all; it's a bogus definition, and doesn't define any kind of type, including an incomplete one.  It's probably safer to have clients believe that a bad tag definition has an incomplete type, and then check *why* it is an incomplete type by interrogating the TagDecl.</div><br></div></div></blockquote><div><br class="webkit-block-placeholder"></div><div>I tend to agree with you. If we make this change, the code below will result in 2 errors. Note that both EDG & GCC only produce 1 error (the first one). From my perspective, not flagging the 2nd error is incorrect (though it could lead to some noisy diagnostics, I guess).</div><div><br class="webkit-block-placeholder"></div><div>Neil, does your cfe produce 1 or 2 diagnostics for the following test case?</div><div><br class="webkit-block-placeholder"></div><div>snaroff</div><div><br class="webkit-block-placeholder"></div><div>[steve-naroffs-imac:tools/clang/test] snaroff% cat xx.c</div><div>struct S {</div><div>  int a;</div><div>  int foo();</div><div>};</div><div><br class="webkit-block-placeholder"></div><div>struct S s; </div><div><br class="webkit-block-placeholder"></div><div><div>[steve-naroffs-imac:tools/clang/test] snaroff% ../../../Debug/bin/clang xx.c</div><div>xx.c:3:7: error: field 'foo' declared as a function</div><div>  int foo();</div><div>      ^</div><div>xx.c:6:10: error: variable has incomplete type 'struct S'</div><div>struct S s;</div><div>         ^</div><div>2 diagnostics generated.</div><div><br class="webkit-block-placeholder"></div></div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"><br><br>For example...<br><br>   case Tagged:<br>      // A tagged type (struct/union/enum/class) is incomplete if the  <br>decl is a<br>      // forward declaration, but not a full definition (C99 6.2.5p22).<br>-    return !cast<TagType>(CanonicalType)->getDecl()->isDefinition();<br>+    TagDecl *TD = cast<TagType>(CanonicalType)->getDecl();<br>+    return !TD->isDefinition() || TD->isInvalidDecl();<br><br>Since this predicate is fairly low-level, I wanted to get some  <br>feedback...<br><br>snaroff<br>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br></blockquote></div><br></div></blockquote></div><br></div>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br></blockquote></div><br></body></html>