diff options
| author | Leonard Chan <leonardchan@google.com> | 2018-06-02 02:58:51 +0000 |
|---|---|---|
| committer | Leonard Chan <leonardchan@google.com> | 2018-06-02 02:58:51 +0000 |
| commit | db55d8331e631e84b07e6fbad923085b4baa9597 (patch) | |
| tree | cab6ad2f57e7522caaa1ded6b6d211583ae6f0b7 /clang/test/Frontend/fixed_point.c | |
| parent | 9c2d52014c95cef4aa0cf7e39ed47a42643c9568 (diff) | |
| download | bcm5719-llvm-db55d8331e631e84b07e6fbad923085b4baa9597.tar.gz bcm5719-llvm-db55d8331e631e84b07e6fbad923085b4baa9597.zip | |
This diff includes changes for supporting the following types.
```
// Primary fixed point types
signed short _Accum s_short_accum;
signed _Accum s_accum;
signed long _Accum s_long_accum;
unsigned short _Accum u_short_accum;
unsigned _Accum u_accum;
unsigned long _Accum u_long_accum;
// Aliased fixed point types
short _Accum short_accum;
_Accum accum;
long _Accum long_accum;
```
This diff only allows for declaration of the fixed point types. Assignment and other operations done on fixed point types according to http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in future patches. The saturated versions of these types and the equivalent `_Fract` types will also be added in future patches.
The tests included are for asserting that we can declare these types.
Differential Revision: https://reviews.llvm.org/D46084
llvm-svn: 333814
Diffstat (limited to 'clang/test/Frontend/fixed_point.c')
| -rw-r--r-- | clang/test/Frontend/fixed_point.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/clang/test/Frontend/fixed_point.c b/clang/test/Frontend/fixed_point.c new file mode 100644 index 00000000000..d64bd55aa0b --- /dev/null +++ b/clang/test/Frontend/fixed_point.c @@ -0,0 +1,57 @@ +// RUN: %clang_cc1 -x c -ffixed-point -ast-dump %s | FileCheck %s --strict-whitespace + +/* Various contexts where type _Accum can appear. */ + +// Primary fixed point types +signed short _Accum s_short_accum; +signed _Accum s_accum; +signed long _Accum s_long_accum; +unsigned short _Accum u_short_accum; +unsigned _Accum u_accum; +unsigned long _Accum u_long_accum; + +// Aliased fixed point types +short _Accum short_accum; +_Accum accum; +long _Accum long_accum; + +// CHECK: |-VarDecl {{.*}} s_short_accum 'short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum' +// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum' +// CHECK-NEXT: |-VarDecl {{.*}} long_accum 'long _Accum' + +#define MIX_TYPE_SPEC(SPEC, SIGN, SIZE, ID) \ + SPEC SIGN SIZE _Accum ID; \ + SIGN SPEC SIZE _Accum ID ## 2; \ + SIGN SIZE SPEC _Accum ID ## 3; \ + SIGN SIZE _Accum SPEC ID ## 4; + +/* Mixing fixed point types with other type specifiers */ + +#define MIX_VOLATILE(SIGN, SIZE, ID) MIX_TYPE_SPEC(volatile, SIGN, SIZE, ID) +#define MIX_ATOMIC(SIGN, SIZE, ID) MIX_TYPE_SPEC(_Atomic, SIGN, SIZE, ID) +#define MIX_CONST(SIGN, SIZE, ID) MIX_TYPE_SPEC(const, SIGN, SIZE, ID) + +MIX_VOLATILE(signed, short, vol_s_short_accum) +MIX_ATOMIC(signed, short, atm_s_short_accum) +MIX_CONST(signed, short, const_s_short_accum) + +// CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum 'volatile short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum2 'volatile short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum3 'volatile short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum4 'volatile short _Accum' + +// CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum '_Atomic(short _Accum)' +// CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum2 '_Atomic(short _Accum)' +// CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum3 '_Atomic(short _Accum)' +// CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum4 '_Atomic(short _Accum)' + +// CHECK-NEXT: |-VarDecl {{.*}} const_s_short_accum 'const short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} const_s_short_accum2 'const short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} const_s_short_accum3 'const short _Accum' +// CHECK-NEXT: `-VarDecl {{.*}} const_s_short_accum4 'const short _Accum' |

