[PATCH] Fixed error recovery if sizeof is used without parenthesis
Richard Smith
richard at metafoo.co.uk
Mon Jan 13 15:24:47 PST 2014
================
Comment at: lib/Parse/ParseTentative.cpp:440-442
@@ -439,2 +439,5 @@
if (TPR == TPResult::Ambiguous()) {
+ if (Context == TypeIdSeparate)
+ TPR = TPResult::False();
+
// We are supposed to be inside parens, so if after the abstract declarator
----------------
This change appears to be redundant.
================
Comment at: include/clang/Parse/Parser.h:1794-1802
@@ -1792,1 +1793,11 @@
+ /// \brief Checks if the current tokens form type-id or expression.
+ /// It is similar to isTypeIdInParens but does not suppose that type-id
+ /// is in parenthesis.
+ bool isTypeIdSeparate(bool &isAmbiguous) {
+ if (getLangOpts().CPlusPlus)
+ return isCXXTypeId(TypeIdSeparate, isAmbiguous);
+ isAmbiguous = false;
+ return isTypeSpecifierQualifier();
+ }
+
----------------
The `isAmbiguous` parameter is unused by the only caller of this function, and wouldn't be filled in anyway. Remove it?
================
Comment at: include/clang/Parse/Parser.h:1775
@@ -1774,2 +1774,3 @@
TypeIdInParens,
+ TypeIdSeparate,
TypeIdAsTemplateArgument
----------------
Can you give this a name that indicates that `isCXXTypeId` will return `false` on ambiguity? `TypeIdUnambiguous` or something.
================
Comment at: include/clang/Parse/Parser.h:1797
@@ +1796,3 @@
+ /// is in parenthesis.
+ bool isTypeIdSeparate(bool &isAmbiguous) {
+ if (getLangOpts().CPlusPlus)
----------------
Likewise, name this `isTypeIdUnambiguously` or similar?
http://llvm-reviews.chandlerc.com/D2440
More information about the cfe-commits
mailing list