Skip to content

Commit d593f6c

Browse files
authored
Revert "[clang] Support fixed point types in C++ (#67750)" (#69963)
This reverts commit a3a7d63. When compiling with MSVC2022 in C++32 mode this is giving an error. Compiling this simple test case: t1.cpp: with -std=c++23 will give the following error: In file included from C:\Users\zahiraam\t1.cpp:1: c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16: error: compile with '-ffixed-point' to enable fixed point types 3329 | _Vbase _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23: error: expected unqualified-id 3329 | _Vbase _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3334:13: error: compile with '-ffixed-point' to enable fixed point types 3334 | _Accum |= _Tmp ? _Mask : _Vbase{0}; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3334:20: error: expected unqualified-id 3334 | _Accum |= _Tmp ? _Mask : _Vbase{0}; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3336:53: error: expected '(' for function-style cast or type construction 3336 | this->_Emplace_back_unchecked(_Accum); | ~~~~~~^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3337:17: error: compile with '-ffixed-point' to enable fixed point types 3337 | _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3337:24: error: expected unqualified-id 3337 | _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3343:49: error: expected '(' for function-style cast or type construction 3343 | this->_Emplace_back_unchecked(_Accum); | ~~~~~~^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3352:16: error: compile with '-ffixed-point' to enable fixed point types 3352 | _Vbase _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3352:26: error: expected unqualified-id 3352 | _Vbase _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3357:13: error: compile with '-ffixed-point' to enable fixed point types 3357 | _Accum |= _Tmp ? _Mask : _Vbase{0}; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3357:20: error: expected unqualified-id 3357 | _Accum |= _Tmp ? _Mask : _Vbase{0}; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3359:46: error: expected '(' for function-style cast or type construction 3359 | this->_Myvec.push_back(_Accum); | ~~~~~~^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3360:17: error: compile with '-ffixed-point' to enable fixed point types 3360 | _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3360:24: error: expected unqualified-id 3360 | _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3366:42: error: expected '(' for function-style cast or type construction 3366 | this->_Myvec.push_back(_Accum); | ~~~~~~^ 16 errors generated. See also comment here: #67750 (comment)
1 parent 77c2b62 commit d593f6c

File tree

8 files changed

+17
-140
lines changed

8 files changed

+17
-140
lines changed

clang/include/clang/Basic/TokenKinds.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof , KEYGNU)
423423
C23_KEYWORD(typeof_unqual , 0)
424424

425425
// ISO/IEC JTC1 SC22 WG14 N1169 Extension
426-
KEYWORD(_Accum , KEYALL)
427-
KEYWORD(_Fract , KEYALL)
428-
KEYWORD(_Sat , KEYALL)
426+
KEYWORD(_Accum , KEYNOCXX)
427+
KEYWORD(_Fract , KEYNOCXX)
428+
KEYWORD(_Sat , KEYNOCXX)
429429

430430
// GNU Extensions (in impl-reserved namespace)
431431
KEYWORD(_Decimal32 , KEYALL)

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2101,7 +2101,7 @@ defm fixed_point : BoolFOption<"fixed-point",
21012101
LangOpts<"FixedPoint">, DefaultFalse,
21022102
PosFlag<SetTrue, [], [ClangOption, CC1Option], "Enable">,
21032103
NegFlag<SetFalse, [], [ClangOption], "Disable">,
2104-
BothFlags<[], [ClangOption], " fixed point types">>;
2104+
BothFlags<[], [ClangOption], " fixed point types">>, ShouldParseIf<!strconcat("!", cplusplus.KeyPath)>;
21052105
defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
21062106
LangOpts<"RegisterStaticDestructors">, DefaultTrue,
21072107
NegFlag<SetFalse, [], [ClangOption, CC1Option],

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,21 +3050,12 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
30503050
// UNSUPPORTED: ::= De # IEEE 754r decimal floating point (128 bits)
30513051
// UNSUPPORTED: ::= Df # IEEE 754r decimal floating point (32 bits)
30523052
// ::= Dh # IEEE 754r half-precision floating point (16 bits)
3053-
// ::= DF <number> _ # ISO/IEC TS 18661 binary floating point type _FloatN (N bits);
3053+
// ::= DF <number> _ # ISO/IEC TS 18661 binary floating point
3054+
// type _FloatN (N bits);
30543055
// ::= Di # char32_t
30553056
// ::= Ds # char16_t
30563057
// ::= Dn # std::nullptr_t (i.e., decltype(nullptr))
3057-
// ::= [DS] DA # N1169 fixed-point [_Sat] T _Accum
3058-
// ::= [DS] DR # N1169 fixed-point [_Sat] T _Fract
30593058
// ::= u <source-name> # vendor extended type
3060-
//
3061-
// <fixed-point-size>
3062-
// ::= s # short
3063-
// ::= t # unsigned short
3064-
// ::= i # plain
3065-
// ::= j # unsigned
3066-
// ::= l # long
3067-
// ::= m # unsigned long
30683059
std::string type_name;
30693060
// Normalize integer types as vendor extended types:
30703061
// u<length>i<type size>
@@ -3209,77 +3200,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
32093200
Out << "DF16_";
32103201
break;
32113202
case BuiltinType::ShortAccum:
3212-
Out << "DAs";
3213-
break;
32143203
case BuiltinType::Accum:
3215-
Out << "DAi";
3216-
break;
32173204
case BuiltinType::LongAccum:
3218-
Out << "DAl";
3219-
break;
32203205
case BuiltinType::UShortAccum:
3221-
Out << "DAt";
3222-
break;
32233206
case BuiltinType::UAccum:
3224-
Out << "DAj";
3225-
break;
32263207
case BuiltinType::ULongAccum:
3227-
Out << "DAm";
3228-
break;
32293208
case BuiltinType::ShortFract:
3230-
Out << "DRs";
3231-
break;
32323209
case BuiltinType::Fract:
3233-
Out << "DRi";
3234-
break;
32353210
case BuiltinType::LongFract:
3236-
Out << "DRl";
3237-
break;
32383211
case BuiltinType::UShortFract:
3239-
Out << "DRt";
3240-
break;
32413212
case BuiltinType::UFract:
3242-
Out << "DRj";
3243-
break;
32443213
case BuiltinType::ULongFract:
3245-
Out << "DRm";
3246-
break;
32473214
case BuiltinType::SatShortAccum:
3248-
Out << "DSDAs";
3249-
break;
32503215
case BuiltinType::SatAccum:
3251-
Out << "DSDAi";
3252-
break;
32533216
case BuiltinType::SatLongAccum:
3254-
Out << "DSDAl";
3255-
break;
32563217
case BuiltinType::SatUShortAccum:
3257-
Out << "DSDAt";
3258-
break;
32593218
case BuiltinType::SatUAccum:
3260-
Out << "DSDAj";
3261-
break;
32623219
case BuiltinType::SatULongAccum:
3263-
Out << "DSDAm";
3264-
break;
32653220
case BuiltinType::SatShortFract:
3266-
Out << "DSDRs";
3267-
break;
32683221
case BuiltinType::SatFract:
3269-
Out << "DSDRi";
3270-
break;
32713222
case BuiltinType::SatLongFract:
3272-
Out << "DSDRl";
3273-
break;
32743223
case BuiltinType::SatUShortFract:
3275-
Out << "DSDRt";
3276-
break;
32773224
case BuiltinType::SatUFract:
3278-
Out << "DSDRj";
3279-
break;
32803225
case BuiltinType::SatULongFract:
3281-
Out << "DSDRm";
3282-
break;
3226+
llvm_unreachable("Fixed point types are disabled for c++");
32833227
case BuiltinType::Half:
32843228
Out << "Dh";
32853229
break;

clang/lib/Parse/ParseExpr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,9 +1574,6 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
15741574
case tok::kw_typename:
15751575
case tok::kw_typeof:
15761576
case tok::kw___vector:
1577-
case tok::kw__Accum:
1578-
case tok::kw__Fract:
1579-
case tok::kw__Sat:
15801577
#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
15811578
#include "clang/Basic/OpenCLImageTypes.def"
15821579
{

clang/lib/Parse/ParseExprCXX.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,15 +2354,6 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
23542354
case tok::kw_bool:
23552355
DS.SetTypeSpecType(DeclSpec::TST_bool, Loc, PrevSpec, DiagID, Policy);
23562356
break;
2357-
case tok::kw__Accum:
2358-
DS.SetTypeSpecType(DeclSpec::TST_accum, Loc, PrevSpec, DiagID, Policy);
2359-
break;
2360-
case tok::kw__Fract:
2361-
DS.SetTypeSpecType(DeclSpec::TST_fract, Loc, PrevSpec, DiagID, Policy);
2362-
break;
2363-
case tok::kw__Sat:
2364-
DS.SetTypeSpecSat(Loc, PrevSpec, DiagID);
2365-
break;
23662357
#define GENERIC_IMAGE_TYPE(ImgType, Id) \
23672358
case tok::kw_##ImgType##_t: \
23682359
DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, DiagID, \

clang/lib/Parse/ParseTentative.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,9 +1775,6 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
17751775
case tok::kw___ibm128:
17761776
case tok::kw_void:
17771777
case tok::annot_decltype:
1778-
case tok::kw__Accum:
1779-
case tok::kw__Fract:
1780-
case tok::kw__Sat:
17811778
#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
17821779
#include "clang/Basic/OpenCLImageTypes.def"
17831780
if (NextToken().is(tok::l_paren))
@@ -1897,9 +1894,6 @@ bool Parser::isCXXDeclarationSpecifierAType() {
18971894
case tok::kw_void:
18981895
case tok::kw___unknown_anytype:
18991896
case tok::kw___auto_type:
1900-
case tok::kw__Accum:
1901-
case tok::kw__Fract:
1902-
case tok::kw__Sat:
19031897
#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
19041898
#include "clang/Basic/OpenCLImageTypes.def"
19051899
return true;

clang/test/CodeGenCXX/fixed-point-mangle.cpp

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
// RUN: %clang_cc1 -x c++ %s -verify -DWITHOUT_FIXED_POINT
2-
// RUN: %clang_cc1 -x c++ %s -verify -ffixed-point
1+
// RUN: %clang_cc1 -x c++ %s -verify
2+
// RUN: %clang_cc1 -x c++ -ffixed-point %s -verify
33

4-
#ifdef WITHOUT_FIXED_POINT
5-
_Accum accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
6-
// expected-error@-1{{a type specifier is required for all declarations}}
7-
_Fract fract; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
8-
// expected-error@-1{{a type specifier is required for all declarations}}
9-
_Sat _Accum sat_accum; // expected-error 2{{compile with '-ffixed-point' to enable fixed point types}}
10-
// expected-error@-1{{a type specifier is required for all declarations}}
11-
#endif
4+
// Name namgling is not provided for fixed point types in c++
5+
6+
_Accum accum; // expected-error{{unknown type name '_Accum'}}
7+
_Fract fract; // expected-error{{unknown type name '_Fract'}}
8+
_Sat _Accum sat_accum; // expected-error{{unknown type name '_Sat'}}
9+
// expected-error@-1{{expected ';' after top level declarator}}
1210

1311
int accum_int = 10k; // expected-error{{invalid suffix 'k' on integer constant}}
1412
int fract_int = 10r; // expected-error{{invalid suffix 'r' on integer constant}}
15-
#ifdef WITHOUT_FIXED_POINT
16-
float accum_flt = 0.0k; // expected-error{{invalid suffix 'k' on floating constant}}
17-
float fract_flt = 0.0r; // expected-error{{invalid suffix 'r' on floating constant}}
18-
#endif
13+
float accum_flt = 10.0k; // expected-error{{invalid suffix 'k' on floating constant}}
14+
float fract_flt = 10.0r; // expected-error{{invalid suffix 'r' on floating constant}}

0 commit comments

Comments
 (0)