<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello Stepan,<div><br><div><div>On Sep 21, 2011, at 1:09 AM, Stepan Dyatkovskiy wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi,</div><div>Please find the fixed patch.</div></blockquote><div><br></div><div>Index: test/Parser/2011-09-20-UsingTypenameIdentifiers.cpp</div><div>===================================================================</div><div>--- test/Parser/2011-09-20-UsingTypenameIdentifiers.cpp<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 0)</div><div>+++ test/Parser/2011-09-20-UsingTypenameIdentifiers.cpp<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 0)</div><div>@@ -0,0 +1,16 @@</div><div><br></div><div>Please fold this test into an existing test for 'using typename'. </div><div><br></div><div><div>Index: lib/Parse/ParseDeclCXX.cpp</div><div>===================================================================</div><div>--- lib/Parse/ParseDeclCXX.cpp<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 140239)</div><div>+++ lib/Parse/ParseDeclCXX.cpp<span class="Apple-tab-span" style="white-space:pre"> </span>(working copy)</div><div>@@ -433,12 +433,14 @@</div><div> Decl **OwnedType) {</div><div> CXXScopeSpec SS;</div><div> SourceLocation TypenameLoc;</div><div>+ SourceLocation TypenameEndLoc;</div><div> bool IsTypeName;</div><div> </div><div> // Ignore optional 'typename'.</div><div> // FIXME: This is wrong; we should parse this as a typename-specifier.</div><div> if (<a href="http://Tok.is">Tok.is</a>(tok::kw_typename)) {</div><div> TypenameLoc = Tok.getLocation();</div><div>+ TypenameEndLoc = TypenameLoc.getLocWithOffset(Tok.getLength());</div><div> ConsumeToken();</div><div> IsTypeName = true;</div><div> }</div><div>@@ -545,6 +547,15 @@</div><div> return 0;</div><div> }</div><div> </div><div>+ // "typename" keyword is allowed for identifiers only,</div><div>+ // because it may be a type definition.</div><div>+ if (IsTypeName && Name.getKind() != UnqualifiedId::IK_Identifier) {</div><div>+ Diag(Name.getSourceRange().getBegin(), diag::err_typename_identifiers_only)</div><div>+ << FixItHint::CreateRemoval(SourceRange(TypenameLoc, TypenameEndLoc));</div><div>+ // Proceed parsing, but reset the IsTypeName flag.</div><div>+ IsTypeName = false;</div><div>+ }</div><div><br></div><div>The fix & recovery look good, but you don't actually need TypenameEndLoc, since the end of a SourceRange points to the beginning of the last token in the source range. There's a short explanation here:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> <a href="http://clang.llvm.org/docs/InternalsManual.html#SourceRange">http://clang.llvm.org/docs/InternalsManual.html#SourceRange</a></span></div></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>- Doug</div><div><br></div><blockquote type="cite"><div> </div><div>Regards,</div><div>Stepan</div><div>20.09.2011, 22:59, "David Blaikie" <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>>:</div><blockquote><div><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid #cccccc;padding-left:1ex;">C++ allows "typename" keywords with identifiers only. In this case compiler interpret identifier as type definition. Clang doesn't check for this case and crash.<br> Please find the patch attached for review.</blockquote><div>Could you simplify the test case from the bug & include it in the change? (& the diagnostic message should probably use the word "typename" not "type name" (since it refers to an identifier). You could also, potentially, include a removal fixit to remove the typename token if you think that might be the likely fix (seems to be in this case))</div><div>- David </div></div><p>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a></p></blockquote><span><bugfix10925.patch></span>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits<br></blockquote></div><br></div></body></html>