[clang] [clang] Support fixed point types in C++ (PR #67750)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 23 06:57:00 PDT 2023


AaronBallman wrote:

This is introducing an extension from C into C++ -- was there an RFC or something discussed about whether we wish to support this in C++? This breaks code in system headers entirely unrelated to fixed point:
```
#include <functional>
#include <iostream>

int main(int argc, char* argv[]) {
    std:: plus<int> x;
    int a = x((int)30, (int)5);
    int b = 35;
    std::cout << a << "vs" << b << std::endl;
}
```
when compiled against MSVC 2022 headers in C++23 mode gives:
```
F:\source\llvm-project>llvm\out\build\x64-Debug\bin\clang.exe -std=c++23 -fsyntax-only "C:\Users\aballman\OneDrive - Intel Corporation\Desktop\test.cpp"
In file included from C:\Users\aballman\OneDrive - Intel Corporation\Desktop\test.cpp:1:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\functional:19:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\unordered_map:11:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\xhash:14:
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3263:16: error:
      compile with '-ffixed-point' to enable fixed point types
 3263 |         _Vbase _Accum = 0;
      |                ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3263:23: error:
      expected unqualified-id
 3263 |         _Vbase _Accum = 0;
      |                       ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3268:13: error:
      compile with '-ffixed-point' to enable fixed point types
 3268 |             _Accum |= _Tmp ? _Mask : _Vbase{0};
      |             ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3268:20: error:
      expected unqualified-id
 3268 |             _Accum |= _Tmp ? _Mask : _Vbase{0};
      |                    ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3270:53: error:
      expected '(' for function-style cast or type construction
 3270 |                 this->_Emplace_back_unchecked(_Accum);
      |                                               ~~~~~~^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3271:17: error:
      compile with '-ffixed-point' to enable fixed point types
 3271 |                 _Accum = 0;
      |                 ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3271:24: error:
      expected unqualified-id
 3271 |                 _Accum = 0;
      |                        ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3277:49: error:
      expected '(' for function-style cast or type construction
 3277 |             this->_Emplace_back_unchecked(_Accum);
      |                                           ~~~~~~^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3286:16: error:
      compile with '-ffixed-point' to enable fixed point types
 3286 |         _Vbase _Accum    = 0;
      |                ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3286:26: error:
      expected unqualified-id
 3286 |         _Vbase _Accum    = 0;
      |                          ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3291:13: error:
      compile with '-ffixed-point' to enable fixed point types
 3291 |             _Accum |= _Tmp ? _Mask : _Vbase{0};
      |             ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3291:20: error:
      expected unqualified-id
 3291 |             _Accum |= _Tmp ? _Mask : _Vbase{0};
      |                    ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3293:46: error:
      expected '(' for function-style cast or type construction
 3293 |                 this->_Myvec.push_back(_Accum);
      |                                        ~~~~~~^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3294:17: error:
      compile with '-ffixed-point' to enable fixed point types
 3294 |                 _Accum = 0;
      |                 ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3294:24: error:
      expected unqualified-id
 3294 |                 _Accum = 0;
      |                        ^
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include\vector:3300:42: error:
      expected '(' for function-style cast or type construction
 3300 |             this->_Myvec.push_back(_Accum);
      |                                    ~~~~~~^
16 errors generated.
```
because Microsoft is already using this reserved identifier as part of their implementation in `<algorithm>` and `<vector>`.

This needs to be reverted temporarily until this issue can be resolved.

https://github.com/llvm/llvm-project/pull/67750


More information about the cfe-commits mailing list