Skip to content

Revert "[clang] Support fixed point types in C++ (#67750)" #69963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clang/include/clang/Basic/TokenKinds.def
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ C23_KEYWORD(typeof , KEYGNU)
C23_KEYWORD(typeof_unqual , 0)

// ISO/IEC JTC1 SC22 WG14 N1169 Extension
KEYWORD(_Accum , KEYALL)
KEYWORD(_Fract , KEYALL)
KEYWORD(_Sat , KEYALL)
KEYWORD(_Accum , KEYNOCXX)
KEYWORD(_Fract , KEYNOCXX)
KEYWORD(_Sat , KEYNOCXX)

// GNU Extensions (in impl-reserved namespace)
KEYWORD(_Decimal32 , KEYALL)
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2101,7 +2101,7 @@ defm fixed_point : BoolFOption<"fixed-point",
LangOpts<"FixedPoint">, DefaultFalse,
PosFlag<SetTrue, [], [ClangOption, CC1Option], "Enable">,
NegFlag<SetFalse, [], [ClangOption], "Disable">,
BothFlags<[], [ClangOption], " fixed point types">>;
BothFlags<[], [ClangOption], " fixed point types">>, ShouldParseIf<!strconcat("!", cplusplus.KeyPath)>;
defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
LangOpts<"RegisterStaticDestructors">, DefaultTrue,
NegFlag<SetFalse, [], [ClangOption, CC1Option],
Expand Down
62 changes: 3 additions & 59 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3050,21 +3050,12 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
// UNSUPPORTED: ::= De # IEEE 754r decimal floating point (128 bits)
// UNSUPPORTED: ::= Df # IEEE 754r decimal floating point (32 bits)
// ::= Dh # IEEE 754r half-precision floating point (16 bits)
// ::= DF <number> _ # ISO/IEC TS 18661 binary floating point type _FloatN (N bits);
// ::= DF <number> _ # ISO/IEC TS 18661 binary floating point
// type _FloatN (N bits);
// ::= Di # char32_t
// ::= Ds # char16_t
// ::= Dn # std::nullptr_t (i.e., decltype(nullptr))
// ::= [DS] DA # N1169 fixed-point [_Sat] T _Accum
// ::= [DS] DR # N1169 fixed-point [_Sat] T _Fract
// ::= u <source-name> # vendor extended type
//
// <fixed-point-size>
// ::= s # short
// ::= t # unsigned short
// ::= i # plain
// ::= j # unsigned
// ::= l # long
// ::= m # unsigned long
std::string type_name;
// Normalize integer types as vendor extended types:
// u<length>i<type size>
Expand Down Expand Up @@ -3209,77 +3200,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
Out << "DF16_";
break;
case BuiltinType::ShortAccum:
Out << "DAs";
break;
case BuiltinType::Accum:
Out << "DAi";
break;
case BuiltinType::LongAccum:
Out << "DAl";
break;
case BuiltinType::UShortAccum:
Out << "DAt";
break;
case BuiltinType::UAccum:
Out << "DAj";
break;
case BuiltinType::ULongAccum:
Out << "DAm";
break;
case BuiltinType::ShortFract:
Out << "DRs";
break;
case BuiltinType::Fract:
Out << "DRi";
break;
case BuiltinType::LongFract:
Out << "DRl";
break;
case BuiltinType::UShortFract:
Out << "DRt";
break;
case BuiltinType::UFract:
Out << "DRj";
break;
case BuiltinType::ULongFract:
Out << "DRm";
break;
case BuiltinType::SatShortAccum:
Out << "DSDAs";
break;
case BuiltinType::SatAccum:
Out << "DSDAi";
break;
case BuiltinType::SatLongAccum:
Out << "DSDAl";
break;
case BuiltinType::SatUShortAccum:
Out << "DSDAt";
break;
case BuiltinType::SatUAccum:
Out << "DSDAj";
break;
case BuiltinType::SatULongAccum:
Out << "DSDAm";
break;
case BuiltinType::SatShortFract:
Out << "DSDRs";
break;
case BuiltinType::SatFract:
Out << "DSDRi";
break;
case BuiltinType::SatLongFract:
Out << "DSDRl";
break;
case BuiltinType::SatUShortFract:
Out << "DSDRt";
break;
case BuiltinType::SatUFract:
Out << "DSDRj";
break;
case BuiltinType::SatULongFract:
Out << "DSDRm";
break;
llvm_unreachable("Fixed point types are disabled for c++");
case BuiltinType::Half:
Out << "Dh";
break;
Expand Down
3 changes: 0 additions & 3 deletions clang/lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1574,9 +1574,6 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
case tok::kw_typename:
case tok::kw_typeof:
case tok::kw___vector:
case tok::kw__Accum:
case tok::kw__Fract:
case tok::kw__Sat:
#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
#include "clang/Basic/OpenCLImageTypes.def"
{
Expand Down
9 changes: 0 additions & 9 deletions clang/lib/Parse/ParseExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2354,15 +2354,6 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
case tok::kw_bool:
DS.SetTypeSpecType(DeclSpec::TST_bool, Loc, PrevSpec, DiagID, Policy);
break;
case tok::kw__Accum:
DS.SetTypeSpecType(DeclSpec::TST_accum, Loc, PrevSpec, DiagID, Policy);
break;
case tok::kw__Fract:
DS.SetTypeSpecType(DeclSpec::TST_fract, Loc, PrevSpec, DiagID, Policy);
break;
case tok::kw__Sat:
DS.SetTypeSpecSat(Loc, PrevSpec, DiagID);
break;
#define GENERIC_IMAGE_TYPE(ImgType, Id) \
case tok::kw_##ImgType##_t: \
DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, DiagID, \
Expand Down
6 changes: 0 additions & 6 deletions clang/lib/Parse/ParseTentative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1775,9 +1775,6 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
case tok::kw___ibm128:
case tok::kw_void:
case tok::annot_decltype:
case tok::kw__Accum:
case tok::kw__Fract:
case tok::kw__Sat:
#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
#include "clang/Basic/OpenCLImageTypes.def"
if (NextToken().is(tok::l_paren))
Expand Down Expand Up @@ -1897,9 +1894,6 @@ bool Parser::isCXXDeclarationSpecifierAType() {
case tok::kw_void:
case tok::kw___unknown_anytype:
case tok::kw___auto_type:
case tok::kw__Accum:
case tok::kw__Fract:
case tok::kw__Sat:
#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
#include "clang/Basic/OpenCLImageTypes.def"
return true;
Expand Down
45 changes: 0 additions & 45 deletions clang/test/CodeGenCXX/fixed-point-mangle.cpp

This file was deleted.

24 changes: 10 additions & 14 deletions clang/test/Frontend/fixed_point_errors.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
// RUN: %clang_cc1 -x c++ %s -verify -DWITHOUT_FIXED_POINT
// RUN: %clang_cc1 -x c++ %s -verify -ffixed-point
// RUN: %clang_cc1 -x c++ %s -verify
// RUN: %clang_cc1 -x c++ -ffixed-point %s -verify

#ifdef WITHOUT_FIXED_POINT
_Accum accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
// expected-error@-1{{a type specifier is required for all declarations}}
_Fract fract; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
// expected-error@-1{{a type specifier is required for all declarations}}
_Sat _Accum sat_accum; // expected-error 2{{compile with '-ffixed-point' to enable fixed point types}}
// expected-error@-1{{a type specifier is required for all declarations}}
#endif
// Name namgling is not provided for fixed point types in c++

_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}}

int accum_int = 10k; // expected-error{{invalid suffix 'k' on integer constant}}
int fract_int = 10r; // expected-error{{invalid suffix 'r' on integer constant}}
#ifdef WITHOUT_FIXED_POINT
float accum_flt = 0.0k; // expected-error{{invalid suffix 'k' on floating constant}}
float fract_flt = 0.0r; // expected-error{{invalid suffix 'r' on floating constant}}
#endif
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}}