<html><body 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></body></html>