]> granicus.if.org Git - clang/commit
[Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals
authorLeonard Chan <leonardchan@google.com>
Wed, 20 Jun 2018 17:19:40 +0000 (17:19 +0000)
committerLeonard Chan <leonardchan@google.com>
Wed, 20 Jun 2018 17:19:40 +0000 (17:19 +0000)
commit84dd23f357de28ff35ffb7343d72cbfc79e49130
tree7ec94dafa03219c940a7dff6086b060e16fb9eb4
parent2e7bf27afabf7dd4fce58a26b0eee4b60c42f337
[Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals

This diff includes the logic for setting the precision bits for each primary fixed point type in the target info and logic for initializing a fixed point literal.

Fixed point literals are declared using the suffixes

```
hr: short _Fract
uhr: unsigned short _Fract
r: _Fract
ur: unsigned _Fract
lr: long _Fract
ulr: unsigned long _Fract
hk: short _Accum
uhk: unsigned short _Accum
k: _Accum
uk: unsigned _Accum
```
Errors are also thrown for illegal literal values

```
unsigned short _Accum u_short_accum = 256.0uhk;   // expected-error{{the integral part of this literal is too large for this unsigned _Accum type}}
```

Differential Revision: https://reviews.llvm.org/D46915

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335148 91177308-0d34-0410-b5e6-96231b3b80d8
40 files changed:
include/clang-c/Index.h
include/clang/AST/ASTContext.h
include/clang/AST/Expr.h
include/clang/AST/RecursiveASTVisitor.h
include/clang/AST/Type.h
include/clang/Basic/DiagnosticCommonKinds.td
include/clang/Basic/LangOptions.def
include/clang/Basic/StmtNodes.td
include/clang/Basic/TargetInfo.h
include/clang/Driver/Options.td
include/clang/Lex/LiteralSupport.h
lib/AST/ASTContext.cpp
lib/AST/ASTDumper.cpp
lib/AST/Expr.cpp
lib/AST/ExprClassification.cpp
lib/AST/ExprConstant.cpp
lib/AST/ItaniumMangle.cpp
lib/AST/StmtPrinter.cpp
lib/AST/StmtProfile.cpp
lib/AST/Type.cpp
lib/Basic/TargetInfo.cpp
lib/Basic/Targets.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGExprScalar.cpp
lib/Driver/ToolChains/Clang.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Lex/LiteralSupport.cpp
lib/Sema/SemaExceptionSpec.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/TreeTransform.h
lib/Serialization/ASTReaderStmt.cpp
lib/Serialization/ASTWriterStmt.cpp
lib/StaticAnalyzer/Core/ExprEngine.cpp
test/Frontend/fixed_point.c
test/Frontend/fixed_point_bit_widths.c
test/Frontend/fixed_point_declarations.c [new file with mode: 0644]
test/Frontend/fixed_point_errors.c
test/Frontend/fixed_point_same_fbits.c [new file with mode: 0644]
tools/libclang/CIndex.cpp
tools/libclang/CXCursor.cpp