<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 17, 2012, at 12:05 AM, Sebastian Redl wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On 17.02.2012, at 04:49, Douglas Gregor wrote:<br><br><blockquote type="cite">Author: dgregor<br></blockquote><blockquote type="cite">Date: Thu Feb 16 21:49:44 2012<br></blockquote><blockquote type="cite">New Revision: 150790<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=150790&view=rev">http://llvm.org/viewvc/llvm-project?rev=150790&view=rev</a><br></blockquote><blockquote type="cite">Log:<br></blockquote><blockquote type="cite">Disambiguate between C++11 lambda expressions and C99 array<br></blockquote><blockquote type="cite">designators in the parser. In the worst case, this disambiguation<br></blockquote><blockquote type="cite">requires tentative parsing just past the closing ']', but for most<br></blockquote><blockquote type="cite">cases we'll be able to tell by looking ahead just one token (without<br></blockquote><blockquote type="cite">going into the heavyweight tentative parsing machinery).<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Modified:<br></blockquote><blockquote type="cite"> cfe/trunk/include/clang/Parse/Parser.h<br></blockquote><blockquote type="cite"> cfe/trunk/lib/Parse/ParseInit.cpp<br></blockquote><blockquote type="cite"> cfe/trunk/test/Parser/cxx0x-lambda-expressions.cpp<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Modified: cfe/trunk/lib/Parse/ParseInit.cpp<br></blockquote><blockquote type="cite">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=150790&r1=150789&r2=150790&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=150790&r1=150789&r2=150790&view=diff</a><br></blockquote><blockquote type="cite">==============================================================================<br></blockquote><blockquote type="cite">--- cfe/trunk/lib/Parse/ParseInit.cpp (original)<br></blockquote><blockquote type="cite">+++ cfe/trunk/lib/Parse/ParseInit.cpp Thu Feb 16 21:49:44 2012<br></blockquote><blockquote type="cite">@@ -21,15 +21,86 @@<br></blockquote><blockquote type="cite">using namespace clang;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">-/// MayBeDesignationStart - Return true if this token might be the start of a<br></blockquote><blockquote type="cite">-/// designator. If we can tell it is impossible that it is a designator, return<br></blockquote><blockquote type="cite">-/// false.<br></blockquote><blockquote type="cite">-static bool MayBeDesignationStart(tok::TokenKind K, Preprocessor &PP) {<br></blockquote><blockquote type="cite">- switch (K) {<br></blockquote><blockquote type="cite">- default: return false;<br></blockquote><blockquote type="cite">+/// MayBeDesignationStart - Return true if the current token might be the start <br></blockquote><blockquote type="cite">+/// of a designator. If we can tell it is impossible that it is a designator, <br></blockquote><blockquote type="cite">+/// return false.<br></blockquote><blockquote type="cite">+bool Parser::MayBeDesignationStart() {<br></blockquote><blockquote type="cite">+ switch (Tok.getKind()) {<br></blockquote><blockquote type="cite">+ default: <br></blockquote><blockquote type="cite">+ return false;<br></blockquote><blockquote type="cite">+ <br></blockquote><blockquote type="cite"> case tok::period: // designator: '.' identifier<br></blockquote><blockquote type="cite">- case tok::l_square: // designator: array-designator<br></blockquote><blockquote type="cite">+ return true;<br></blockquote><blockquote type="cite">+ <br></blockquote><blockquote type="cite">+ case tok::l_square: { // designator: array-designator<br></blockquote><blockquote type="cite">+ if (!PP.getLangOptions().CPlusPlus0x)<br></blockquote><blockquote type="cite"> return true;<br></blockquote><blockquote type="cite">+ <br></blockquote><br>Maybe reduce nesting by breaking out of the switch here?<font class="Apple-style-span" color="#00731d"><br></font></div></blockquote><br></div><div>Sure. r150817 keeps the easy cases in the switch, but moves the tentative parsing below.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>- Doug</div><br></body></html>