[all-commits] [llvm/llvm-project] 8cba72: Implement literal suffixes for _BitInt
Aaron Ballman via All-commits
all-commits at lists.llvm.org
Mon Mar 14 06:24:35 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 8cba72177dcd8de5d37177dbaf2347e5c1f0f1e8
https://github.com/llvm/llvm-project/commit/8cba72177dcd8de5d37177dbaf2347e5c1f0f1e8
Author: Aaron Ballman <aaron at aaronballman.com>
Date: 2022-03-14 (Mon, 14 Mar 2022)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/DiagnosticCommonKinds.td
M clang/include/clang/Lex/LiteralSupport.h
M clang/lib/AST/StmtPrinter.cpp
M clang/lib/Lex/LiteralSupport.cpp
M clang/lib/Lex/PPExpressions.cpp
M clang/lib/Sema/SemaExpr.cpp
A clang/test/AST/bitint-suffix.c
A clang/test/Lexer/bitint-constants-compat.c
A clang/test/Lexer/bitint-constants.c
M llvm/include/llvm/ADT/APInt.h
M llvm/lib/Support/APInt.cpp
Log Message:
-----------
Implement literal suffixes for _BitInt
WG14 adopted N2775 (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2775.pdf)
at our Feb 2022 meeting. This paper adds a literal suffix for
bit-precise types that automatically sizes the bit-precise type to be
the smallest possible legal _BitInt type that can represent the literal
value. The suffix chosen is wb (for a signed bit-precise type) which
can be combined with the u suffix (for an unsigned bit-precise type).
The preprocessor continues to operate as-if all integer types were
intmax_t/uintmax_t, including bit-precise integer types. It is a
constraint violation if the bit-precise literal is too large to fit
within that type in the context of the preprocessor (when still using
a pp-number preprocessing token), but it is not a constraint violation
in other circumstances. This allows you to make bit-precise integer
literals that are wider than what the preprocessor currently supports
in order to initialize variables, etc.
More information about the All-commits
mailing list