<div dir="ltr">Any comments?</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/12/19 Serge Pavlov <span dir="ltr"><<a href="mailto:sepavloff@gmail.com" target="_blank">sepavloff@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">sepavloff added you to the CC list for the revision "Fixed error recovery if sizeof is used without parenthesis".<br>
<div class="HOEnZb"><div class="h5"><br>
Changes made in r192200 fixed PR16992, which requested fixit suggesting<br>
parenthesis if sizeof is followed by type-id. However expression in form<br>
T() followed by ')' was incorrectly considered as a type-id if 'T' is<br>
typedef name. This change fixes this case.<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D2440" target="_blank">http://llvm-reviews.chandlerc.com/D2440</a><br>
<br>
Files:<br>
include/clang/Parse/Parser.h<br>
lib/Parse/ParseExpr.cpp<br>
lib/Parse/ParseTentative.cpp<br>
test/SemaCXX/expressions.cpp<br>
<br>
Index: include/clang/Parse/Parser.h<br>
===================================================================<br>
--- include/clang/Parse/Parser.h<br>
+++ include/clang/Parse/Parser.h<br>
@@ -1772,6 +1772,7 @@<br>
/// disambiguation will occur.<br>
enum TentativeCXXTypeIdContext {<br>
TypeIdInParens,<br>
+ TypeIdSeparate,<br>
TypeIdAsTemplateArgument<br>
};<br>
<br>
@@ -1790,6 +1791,16 @@<br>
return isTypeIdInParens(isAmbiguous);<br>
}<br>
<br>
+ /// \brief Checks if the current tokens form type-id or expression.<br>
+ /// It is similar to isTypeIdInParens but does not suppose that type-id<br>
+ /// is in parenthesis.<br>
+ bool isTypeIdSeparate(bool &isAmbiguous) {<br>
+ if (getLangOpts().CPlusPlus)<br>
+ return isCXXTypeId(TypeIdSeparate, isAmbiguous);<br>
+ isAmbiguous = false;<br>
+ return isTypeSpecifierQualifier();<br>
+ }<br>
+<br>
/// isCXXDeclarationStatement - C++-specialized function that disambiguates<br>
/// between a declaration or an expression statement, when parsing function<br>
/// bodies. Returns true for declaration, false for expression.<br>
Index: lib/Parse/ParseExpr.cpp<br>
===================================================================<br>
--- lib/Parse/ParseExpr.cpp<br>
+++ lib/Parse/ParseExpr.cpp<br>
@@ -1493,7 +1493,7 @@<br>
if (OpTok.is(tok::kw_sizeof) || OpTok.is(tok::kw___alignof) ||<br>
OpTok.is(tok::kw_alignof) || OpTok.is(tok::kw__Alignof)) {<br>
bool isAmbiguousTypeId;<br>
- if (isTypeIdInParens(isAmbiguousTypeId)) {<br>
+ if (isTypeIdSeparate(isAmbiguousTypeId)) {<br>
DeclSpec DS(AttrFactory);<br>
ParseSpecifierQualifierList(DS);<br>
Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);<br>
Index: lib/Parse/ParseTentative.cpp<br>
===================================================================<br>
--- lib/Parse/ParseTentative.cpp<br>
+++ lib/Parse/ParseTentative.cpp<br>
@@ -437,9 +437,12 @@<br>
TPR = TPResult::True();<br>
<br>
if (TPR == TPResult::Ambiguous()) {<br>
+ if (Context == TypeIdSeparate)<br>
+ TPR = TPResult::False();<br>
+<br>
// We are supposed to be inside parens, so if after the abstract declarator<br>
// we encounter a ')' this is a type-id, otherwise it's an expression.<br>
- if (Context == TypeIdInParens && Tok.is(tok::r_paren)) {<br>
+ else if (Context == TypeIdInParens && Tok.is(tok::r_paren)) {<br>
TPR = TPResult::True();<br>
isAmbiguous = true;<br>
<br>
Index: test/SemaCXX/expressions.cpp<br>
===================================================================<br>
--- test/SemaCXX/expressions.cpp<br>
+++ test/SemaCXX/expressions.cpp<br>
@@ -118,3 +118,10 @@<br>
(void)s1.foo();<br>
(void)s2.foo();<br>
}<br>
+<br>
+namespace pr16992 {<br>
+ typedef int T;<br>
+ unsigned getsz() {<br>
+ return (sizeof T());<br>
+ }<br>
+}<br>
</div></div><br>_______________________________________________<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" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Thanks,<br>--Serge<br>
</div>