teak-llvm/clang/test/Frontend/fixed_point_not_enabled.c
Leonard Chan e5597ad9f3 [Fixed Point Arithmetic] Fix for bug where integer literals could be treated as fixed point literals
This addresses a bug brought up in https://bugs.llvm.org/show_bug.cgi?id=38161 where integer literals could be treated as fixed point types and throw errors related to fixed point types when the 'k' or 'r' suffix used. The fix also addresses the second issue brought up with the assertion by not treating integers as fixed point types in the first place.

Integers that have suffixes 'k' and 'r' now throw the error `invalid suffix 'k/r' on integer constant`.

A few more tests were also added to ensure that fixed point types, and any errors/warnings related to them, are limited to C for now.

Prior discussion also at https://reviews.llvm.org/D46915.

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

llvm-svn: 337289
2018-07-17 14:58:49 +00:00

22 lines
1.6 KiB
C

// RUN: %clang_cc1 -x c -verify %s
// Primary fixed point types
signed short _Accum s_short_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
signed _Accum s_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
signed long _Accum s_long_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
unsigned short _Accum u_short_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
unsigned _Accum u_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
unsigned long _Accum u_long_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
// Aliased fixed point types
short _Accum short_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
_Accum accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
// expected-warning@-1{{type specifier missing, defaults to 'int'}}
long _Accum long_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
// Cannot use fixed point suffixes
int accum_int = 10k; // expected-error{{invalid suffix 'k' on integer constant}}
int fract_int = 10r; // expected-error{{invalid suffix 'r' on integer constant}}
float accum_flt = 10.0k; // expected-error{{invalid suffix 'k' on floating constant}}
float fract_flt = 10.0r; // expected-error{{invalid suffix 'r' on floating constant}}