[PATCH] D58729: Emit boxed expression as a compile-time constant if the expression inside the parentheses is a string literal

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 5 18:34:34 PST 2019


ahatanak added inline comments.


================
Comment at: test/SemaObjC/boxing-illegal.m:70
+  s = @(L"abc"); // expected-error {{illegal type 'int *' used in a boxed expression}}
+  s = @("\pabc"); // expected-error {{illegal type 'unsigned char *' used in a boxed expression}}
+}
----------------
rjmccall wrote:
> I don't know what `\p` is supposed to be or why it apparently changes the type of the literal to `unsigned char *`, but none of these are ordinary string literals that are invalid as UTF-8.  I mean something like "\xFF", which still has type `char *` but will fail to parse as UTF-8, which will cause normal boxing to fail and return `nil`.
Fixed and added test cases. Boxed expressions now have to be valid UTF-8 string literals in order to be emitted as compile-time constants.

If the string literal in a boxed expression is an invalid UTF-8 string, should we reject it the same way we reject other kinds of string literals (e.g., UTF-16)?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58729/new/

https://reviews.llvm.org/D58729





More information about the cfe-commits mailing list