[PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

Richard Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 23 13:04:30 PDT 2017


rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

I like it, and it seems like it would nicely generalize if there are more cases that we find need this treatment.



================
Comment at: clang/lib/Lex/LiteralSupport.cpp:676-682
-      isLong = false;
-      isUnsigned = false;
-      isLongLong = false;
-      isFloat = false;
-      isHalf = false;
-      isImaginary = false;
-      MicrosoftInteger = 0;
----------------
We should still do this if `s != ThisTokEnd`, rather than relying on `isValidUDSuffix` to also validate that we have a valid built-in suffix. (Eg, if C++20 adds an "in" suffix for "inches", this patch would treat "1.0in" as a valid `_Complex double` literal if no `operator""in` is found, because we don't validate that all the suffix characters are used on the fallback path.)


================
Comment at: clang/lib/Lex/LiteralSupport.cpp:684
+    }
     return;
   }
----------------
Redundant return. Remove? :)


================
Comment at: clang/lib/Sema/SemaExpr.cpp:3355
+                                  /*DiagnoseMissing*/ !Literal.isImaginary)) {
+    case LOLR_Error: {
+      // Lookup failure for imaginary constants isn't fatal, there's still the
----------------
I'd feel a bit more comfortable with a different return value for "lookup failed but we've not issued an error", to make it more obvious that we never return `ExprError()` here without issuing a diagnostic.


https://reviews.llvm.org/D33424





More information about the cfe-commits mailing list