llvm-project/clang/test/Frontend/fixed_point_not_enabled.c
PiJoules 2c65860667
[clang] Remove fixed point arithmetic error (#71884)
Prior to this, clang would always report

```
compile with '-ffixed-point' to enable fixed point types
```

whenever it sees `_Accum`, `_Fract`, or `_Sat` when fixed point
arithmetic is not enabled. This can break existing code that uses these
as variable names and doesn't use fixed point arithmetic like in some
microsoft headers

(https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907).

Fixed point should not raise this error for these cases, so this removes
the error altogether and defaults to the usual error clang gives where
it can see these keywords as either unknown types or regular variables.
2023-11-13 12:31:49 -08:00

18 lines
1.1 KiB
C

// RUN: %clang_cc1 -x c -verify %s
// Primary fixed point types
// Without `-ffixed-point`, these keywords are now treated as typedef'd types or identifiers.
_Accum accum; // expected-error{{unknown type name '_Accum'}}
_Fract fract; // expected-error{{unknown type name '_Fract'}}
_Sat _Accum sat_accum; // expected-error{{unknown type name '_Sat'}}
// expected-error@-1{{expected ';' after top level declarator}}
signed _Accum signed_accum; // expected-error{{expected ';' after top level declarator}}
signed _Fract signed_fract; // expected-error{{expected ';' after top level declarator}}
signed _Sat _Accum signed_sat_accum; // expected-error{{expected ';' after top level declarator}}
// 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}}