Repository navigation
build: Only allow ASCII identifiers - #19094
Conversation
While emoji and other symbols in C++ identifers (as accepted by newer compilers) are fun, they might create confusion during code review, for example because some symbols look very similar. Forbid such extended identifiers for now. This is done by providing `-fno-extended-identifiers`. Thanks to sipa for suggesting this compiler flag.
|
ACK, though as long as we have at least a GCC before 10.0 in our CI, such identifiers won't work regardless. Note that this flag also does not exist for clang (which seems to have no way of disallowing such identifiers, or non-ascii input in general). |
|
Concept ACK. The same is enforced for the python functional tests (emojis in symbol names are not allowed by python, but strings may contain arbitrary utf-8 characters). Edit: It looks like python3 does allow some non-ascii unicode: https://docs.python.org/3/reference/lexical_analysis.html#identifiers |
|
Sorry, I meant ℭ𝔬𝔫𝔠𝔢𝔭𝔱 𝔄ℭ𝔎 |
You're right with regard to CI. Then it's mostly useful for people developing locally, I suppose. I tend to prefer problems being flagged while compiling locally to having to PR and wait for travis to fail. |
There was a problem hiding this comment.
ACK 399d84d
sanity check that -fno-extended-identifiers was not present in build configure on master and is present in this branch
checking whether C++ compiler accepts -fno-extended-identifiers... yes
CC = /usr/bin/ccache gcc
CFLAGS = -g -O2
CPPFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS
CXX = /usr/bin/ccache g++ -std=c++11
CXXFLAGS = -fstack-reuse=none -Wstack-protector -fstack-protector-all
-Wall -Wextra -Wformat -Wvla -Wswitch -Wredundant-decls
-Wunused-variable -Wdate-time -Wsign-compare
-Wno-unused-parameter -Wno-implicit-fallthrough
-g -O2 -fno-extended-identifiers
LDFLAGS = -pthread -Wl,-z,relro -Wl,-z,now -pie
ARFLAGS = cr
edit: gcc version 8.3.0 on debian
|
The gcc 10 release notes kindly include an example to test against https://gcc.gnu.org/gcc-10/changes.html gcc 10: clang 10: compiles emoji and utf-8 without warning |
|
ACK 399d84d -- patch looks correct |
|
ACK 399d84d. |
399d84d build: Only allow ASCII identifiers (Wladimir J. van der Laan) Pull request description: While emoji and other symbols in C++ identifers (as accepted by newer compilers) are fun, they might create confusion during code review, for example because some symbols look very similar. Forbid such extended identifiers for now. This is done by providing `-fno-extended-identifiers`. Thanks to sipa for suggesting this compiler flag. ACKs for top commit: practicalswift: ACK 399d84d -- patch looks correct promag: ACK 399d84d. jonatack: ACK 399d84d fanquake: ACK 399d84d - seems like a good sanity check to enable. Tree-SHA512: 62bfbe8c7e0284ed505c2c8789c1ae74997202d90595f298c2ee1917e5d69fa9b7196a9404ba2cff61f3162b2bbb5616a1591bed3f0534c58617e22009291933
While emoji and other symbols in C++ identifers (as accepted by newer compilers) are fun, they might create confusion during code review, for example because some symbols look very similar. Forbid such extended identifiers for now.
This is done by providing
-fno-extended-identifiers. Thanks to sipa for suggesting this compiler flag.