leonardchan updated this revision to Diff 147400.
leonardchan added a comment.

Added break. We still assign `Result` since it cannot be null at the end of the 
switch stmt, though the value doesn't matter.

Added character `~` to indicate fixed point type followed by string detailing 
the type. I have not added a test to it because logically, I do not think we 
will ever reach that point. This logic is implemented in the `VisitType` 
method, which mostly gets called by visitors to c++ nodes like 
`VisitTemplateParameterList`, but we have disabled the use of fixed point types 
in c++. `VisitType` does get called in `VisitFunctionDecl` but the function 
exits early since we are not reading c++ (line lib/Index/USRGeneration.cpp:238).


Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/accum.c
  test/Frontend/accum_errors.c
  test/Frontend/accum_errors.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===================================================================
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
     BTCASE(Float);
     BTCASE(Double);
     BTCASE(LongDouble);
+    BTCASE(ShortAccum);
+    BTCASE(Accum);
+    BTCASE(LongAccum);
+    BTCASE(UShortAccum);
+    BTCASE(UAccum);
+    BTCASE(ULongAccum);
     BTCASE(Float16);
     BTCASE(Float128);
     BTCASE(NullPtr);
@@ -542,6 +548,12 @@
     TKIND(Float);
     TKIND(Double);
     TKIND(LongDouble);
+    TKIND(ShortAccum);
+    TKIND(Accum);
+    TKIND(LongAccum);
+    TKIND(UShortAccum);
+    TKIND(UAccum);
+    TKIND(ULongAccum);
     TKIND(Float16);
     TKIND(Float128);
     TKIND(NullPtr);
Index: test/Frontend/accum_errors.cpp
===================================================================
--- /dev/null
+++ test/Frontend/accum_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum;     // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum;  // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/accum_errors.c
===================================================================
--- /dev/null
+++ test/Frontend/accum_errors.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
Index: test/Frontend/accum.c
===================================================================
--- /dev/null
+++ test/Frontend/accum.c
@@ -0,0 +1,26 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type _Accum can appear. */
+
+// Primary fixed point types
+signed short _Accum s_short_accum;
+signed _Accum s_accum;
+signed long _Accum s_long_accum;
+unsigned short _Accum u_short_accum;
+unsigned _Accum u_accum;
+unsigned long _Accum u_long_accum;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+
+// CHECK:      |-VarDecl {{.*}} s_short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum'
+// CHECK-NEXT: `-VarDecl {{.*}} long_accum 'long _Accum'
Index: lib/Serialization/ASTReader.cpp
===================================================================
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6816,6 +6816,24 @@
     case PREDEF_TYPE_LONGDOUBLE_ID:
       T = Context.LongDoubleTy;
       break;
+    case PREDEF_TYPE_SHORT_ACCUM_ID:
+      T = Context.ShortAccumTy;
+      break;
+    case PREDEF_TYPE_ACCUM_ID:
+      T = Context.AccumTy;
+      break;
+    case PREDEF_TYPE_LONG_ACCUM_ID:
+      T = Context.LongAccumTy;
+      break;
+    case PREDEF_TYPE_USHORT_ACCUM_ID:
+      T = Context.UnsignedShortAccumTy;
+      break;
+    case PREDEF_TYPE_UACCUM_ID:
+      T = Context.UnsignedAccumTy;
+      break;
+    case PREDEF_TYPE_ULONG_ACCUM_ID:
+      T = Context.UnsignedLongAccumTy;
+      break;
     case PREDEF_TYPE_FLOAT16_ID:
       T = Context.Float16Ty;
       break;
Index: lib/Serialization/ASTCommon.cpp
===================================================================
--- lib/Serialization/ASTCommon.cpp
+++ lib/Serialization/ASTCommon.cpp
@@ -91,6 +91,24 @@
   case BuiltinType::LongDouble:
     ID = PREDEF_TYPE_LONGDOUBLE_ID;
     break;
+  case BuiltinType::ShortAccum:
+    ID = PREDEF_TYPE_SHORT_ACCUM_ID;
+    break;
+  case BuiltinType::Accum:
+    ID = PREDEF_TYPE_ACCUM_ID;
+    break;
+  case BuiltinType::LongAccum:
+    ID = PREDEF_TYPE_LONG_ACCUM_ID;
+    break;
+  case BuiltinType::UShortAccum:
+    ID = PREDEF_TYPE_USHORT_ACCUM_ID;
+    break;
+  case BuiltinType::UAccum:
+    ID = PREDEF_TYPE_UACCUM_ID;
+    break;
+  case BuiltinType::ULongAccum:
+    ID = PREDEF_TYPE_ULONG_ACCUM_ID;
+    break;
   case BuiltinType::Float16:
     ID = PREDEF_TYPE_FLOAT16_ID;
     break;
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1386,6 +1386,48 @@
     }
     break;
   }
+  case DeclSpec::TST_accum: {
+    if (S.getLangOpts().CPlusPlus) {
+      S.Diag(DS.getTypeSpecTypeLoc(), diag::err_fixed_point_only_allowed_in_c);
+      Result = Context.ShortAccumTy;
+      break;
+    }
+
+    if (DS.getTypeSpecSign() != DeclSpec::TSS_unsigned) {
+      switch (DS.getTypeSpecWidth()) {
+        case DeclSpec::TSW_short:
+          Result = Context.ShortAccumTy;
+          break;
+        case DeclSpec::TSW_unspecified:
+          Result = Context.AccumTy;
+          break;
+        case DeclSpec::TSW_long:
+          Result = Context.LongAccumTy;
+          break;
+        case DeclSpec::TSW_longlong:
+          // Unreachable b/c this is caught in final analysis of the DeclSpec.
+          llvm_unreachable("Unable to specify long long as _Accum width");
+          break;
+      }
+    } else {
+      switch (DS.getTypeSpecWidth()) {
+        case DeclSpec::TSW_short:
+          Result = Context.UnsignedShortAccumTy;
+          break;
+        case DeclSpec::TSW_unspecified:
+          Result = Context.UnsignedAccumTy;
+          break;
+        case DeclSpec::TSW_long:
+          Result = Context.UnsignedLongAccumTy;
+          break;
+        case DeclSpec::TSW_longlong:
+          // TODO: Replace with diag
+          llvm_unreachable("Unable to specify long long as _Accum width");
+          break;
+      }
+    }
+    break;
+  }
   case DeclSpec::TST_int128:
     if (!S.Context.getTargetInfo().hasInt128Type())
       S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
Index: lib/Sema/SemaTemplateVariadic.cpp
===================================================================
--- lib/Sema/SemaTemplateVariadic.cpp
+++ lib/Sema/SemaTemplateVariadic.cpp
@@ -829,6 +829,7 @@
   case TST_half:
   case TST_float:
   case TST_double:
+  case TST_Accum:
   case TST_Float16:
   case TST_float128:
   case TST_bool:
Index: lib/Sema/DeclSpec.cpp
===================================================================
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -336,6 +336,7 @@
     case TST_decimal32:
     case TST_decimal64:
     case TST_double:
+    case TST_Accum:
     case TST_Float16:
     case TST_float128:
     case TST_enum:
@@ -506,6 +507,8 @@
   case DeclSpec::TST_half:        return "half";
   case DeclSpec::TST_float:       return "float";
   case DeclSpec::TST_double:      return "double";
+  case DeclSpec::TST_accum:
+    return "_Accum";
   case DeclSpec::TST_float16:     return "_Float16";
   case DeclSpec::TST_float128:    return "__float128";
   case DeclSpec::TST_bool:        return Policy.Bool ? "bool" : "_Bool";
@@ -1096,12 +1099,13 @@
     }
   }
 
-  // signed/unsigned are only valid with int/char/wchar_t.
+  // signed/unsigned are only valid with int/char/wchar_t/_Accum.
   if (TypeSpecSign != TSS_unspecified) {
     if (TypeSpecType == TST_unspecified)
       TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int.
-    else if (TypeSpecType != TST_int  && TypeSpecType != TST_int128 &&
-             TypeSpecType != TST_char && TypeSpecType != TST_wchar) {
+    else if (TypeSpecType != TST_int && TypeSpecType != TST_int128 &&
+             TypeSpecType != TST_char && TypeSpecType != TST_wchar &&
+             TypeSpecType != TST_accum) {
       S.Diag(TSSLoc, diag::err_invalid_sign_spec)
         << getSpecifierName((TST)TypeSpecType, Policy);
       // signed double -> double.
@@ -1116,7 +1120,8 @@
   case TSW_longlong: // long long int
     if (TypeSpecType == TST_unspecified)
       TypeSpecType = TST_int; // short -> short int, long long -> long long int.
-    else if (TypeSpecType != TST_int) {
+    else if (!(TypeSpecType == TST_int ||
+               (TypeSpecType == TST_accum && TypeSpecWidth != TSW_longlong))) {
       S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
           << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
       TypeSpecType = TST_int;
@@ -1126,7 +1131,8 @@
   case TSW_long:  // long double, long int
     if (TypeSpecType == TST_unspecified)
       TypeSpecType = TST_int;  // long -> long int.
-    else if (TypeSpecType != TST_int && TypeSpecType != TST_double) {
+    else if (TypeSpecType != TST_int && TypeSpecType != TST_double &&
+             TypeSpecType != TST_accum) {
       S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
           << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
       TypeSpecType = TST_int;
Index: lib/Parse/ParseDecl.cpp
===================================================================
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -3579,6 +3579,10 @@
       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_float16, Loc, PrevSpec,
                                      DiagID, Policy);
       break;
+    case tok::kw__Accum:
+      isInvalid = DS.SetTypeSpecType(DeclSpec::TST_accum, Loc, PrevSpec, DiagID,
+                                     Policy);
+      break;
     case tok::kw___float128:
       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_float128, Loc, PrevSpec,
                                      DiagID, Policy);
@@ -4591,6 +4595,7 @@
   case tok::kw_half:
   case tok::kw_float:
   case tok::kw_double:
+  case tok::kw__Accum:
   case tok::kw__Float16:
   case tok::kw___float128:
   case tok::kw_bool:
@@ -4667,6 +4672,7 @@
   case tok::kw_half:
   case tok::kw_float:
   case tok::kw_double:
+  case tok::kw__Accum:
   case tok::kw__Float16:
   case tok::kw___float128:
   case tok::kw_bool:
@@ -4824,6 +4830,7 @@
   case tok::kw_half:
   case tok::kw_float:
   case tok::kw_double:
+  case tok::kw__Accum:
   case tok::kw__Float16:
   case tok::kw___float128:
   case tok::kw_bool:
Index: lib/Index/USRGeneration.cpp
===================================================================
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -682,6 +682,16 @@
           c = 'K'; break;
         case BuiltinType::Int128:
           c = 'J'; break;
+        case BuiltinType::ShortAccum:
+        case BuiltinType::Accum:
+        case BuiltinType::LongAccum:
+        case BuiltinType::UShortAccum:
+        case BuiltinType::UAccum:
+        case BuiltinType::ULongAccum:
+          c = '~';  // Special character to indicate we have a fixed point type and
+                    // will be followed by further characters to indicate the
+                    // type.
+          break;
         case BuiltinType::Float16:
         case BuiltinType::Half:
           c = 'h'; break;
@@ -717,6 +727,25 @@
           c = 'e'; break;
       }
       Out << c;
+
+      if (c == '~') {
+        switch (BT->getKind()) {
+          default: llvm_unreachable("Unknown fixed point type");
+          case BuiltinType::ShortAccum:
+            Out << "sA"; break;
+          case BuiltinType::Accum:
+            Out << "A"; break;
+          case BuiltinType::LongAccum:
+            Out << "lA"; break;
+          case BuiltinType::UShortAccum:
+            Out << "UsA"; break;
+          case BuiltinType::UAccum:
+            Out << "UA"; break;
+          case BuiltinType::ULongAccum:
+            Out << "UlA"; break;
+        }
+      }
+
       return;
     }
 
Index: lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2710,6 +2710,12 @@
     case BuiltinType::Char32:
     case BuiltinType::Int128:
     case BuiltinType::UInt128:
+    case BuiltinType::ShortAccum:
+    case BuiltinType::Accum:
+    case BuiltinType::LongAccum:
+    case BuiltinType::UShortAccum:
+    case BuiltinType::UAccum:
+    case BuiltinType::ULongAccum:
       return true;
 
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
Index: lib/CodeGen/CodeGenTypes.cpp
===================================================================
--- lib/CodeGen/CodeGenTypes.cpp
+++ lib/CodeGen/CodeGenTypes.cpp
@@ -439,6 +439,12 @@
     case BuiltinType::WChar_U:
     case BuiltinType::Char16:
     case BuiltinType::Char32:
+    case BuiltinType::ShortAccum:
+    case BuiltinType::Accum:
+    case BuiltinType::LongAccum:
+    case BuiltinType::UShortAccum:
+    case BuiltinType::UAccum:
+    case BuiltinType::ULongAccum:
       ResultType = llvm::IntegerType::get(getLLVMContext(),
                                  static_cast<unsigned>(Context.getTypeSize(T)));
       break;
Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -675,14 +675,20 @@
   case BuiltinType::ULong:
   case BuiltinType::WChar_U:
   case BuiltinType::ULongLong:
+  case BuiltinType::UShortAccum:
+  case BuiltinType::UAccum:
+  case BuiltinType::ULongAccum:
     Encoding = llvm::dwarf::DW_ATE_unsigned;
     break;
   case BuiltinType::Short:
   case BuiltinType::Int:
   case BuiltinType::Int128:
   case BuiltinType::Long:
   case BuiltinType::WChar_S:
   case BuiltinType::LongLong:
+  case BuiltinType::ShortAccum:
+  case BuiltinType::Accum:
+  case BuiltinType::LongAccum:
     Encoding = llvm::dwarf::DW_ATE_signed;
     break;
   case BuiltinType::Bool:
Index: lib/Analysis/PrintfFormatString.cpp
===================================================================
--- lib/Analysis/PrintfFormatString.cpp
+++ lib/Analysis/PrintfFormatString.cpp
@@ -654,6 +654,12 @@
   case BuiltinType::Half:
   case BuiltinType::Float16:
   case BuiltinType::Float128:
+  case BuiltinType::ShortAccum:
+  case BuiltinType::Accum:
+  case BuiltinType::LongAccum:
+  case BuiltinType::UShortAccum:
+  case BuiltinType::UAccum:
+  case BuiltinType::ULongAccum:
     // Various types which are non-trivial to correct.
     return false;
 
Index: lib/AST/TypeLoc.cpp
===================================================================
--- lib/AST/TypeLoc.cpp
+++ lib/AST/TypeLoc.cpp
@@ -342,6 +342,12 @@
   case BuiltinType::LongDouble:
   case BuiltinType::Float16:
   case BuiltinType::Float128:
+  case BuiltinType::ShortAccum:
+  case BuiltinType::Accum:
+  case BuiltinType::LongAccum:
+  case BuiltinType::UShortAccum:
+  case BuiltinType::UAccum:
+  case BuiltinType::ULongAccum:
     llvm_unreachable("Builtin type needs extra local data!");
     // Fall through, if the impossible happens.
       
Index: lib/AST/Type.cpp
===================================================================
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2648,6 +2648,18 @@
     return "double";
   case LongDouble:
     return "long double";
+  case ShortAccum:
+    return "short _Accum";
+  case Accum:
+    return "_Accum";
+  case LongAccum:
+    return "long _Accum";
+  case UShortAccum:
+    return "unsigned short _Accum";
+  case UAccum:
+    return "unsigned _Accum";
+  case ULongAccum:
+    return "unsigned long _Accum";
   case Float16:
     return "_Float16";
   case Float128:
Index: lib/AST/NSAPI.cpp
===================================================================
--- lib/AST/NSAPI.cpp
+++ lib/AST/NSAPI.cpp
@@ -440,6 +440,12 @@
   case BuiltinType::Char32:
   case BuiltinType::Int128:
   case BuiltinType::LongDouble:
+  case BuiltinType::ShortAccum:
+  case BuiltinType::Accum:
+  case BuiltinType::LongAccum:
+  case BuiltinType::UShortAccum:
+  case BuiltinType::UAccum:
+  case BuiltinType::ULongAccum:
   case BuiltinType::UInt128:
   case BuiltinType::Float16:
   case BuiltinType::Float128:
Index: lib/AST/MicrosoftMangle.cpp
===================================================================
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1922,6 +1922,12 @@
     mangleArtificalTagType(TTK_Struct, "_Float16", {"__clang"});
     break;
 
+  case BuiltinType::ShortAccum:
+  case BuiltinType::Accum:
+  case BuiltinType::LongAccum:
+  case BuiltinType::UShortAccum:
+  case BuiltinType::UAccum:
+  case BuiltinType::ULongAccum:
   case BuiltinType::Float128:
   case BuiltinType::Half: {
     DiagnosticsEngine &Diags = Context.getDiags();
Index: lib/AST/ItaniumMangle.cpp
===================================================================
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -2543,6 +2543,13 @@
   case BuiltinType::Float16:
     Out << "DF16_";
     break;
+  case BuiltinType::ShortAccum:
+  case BuiltinType::Accum:
+  case BuiltinType::LongAccum:
+  case BuiltinType::UShortAccum:
+  case BuiltinType::UAccum:
+  case BuiltinType::ULongAccum:
+    llvm_unreachable("Fixed point types are disabled for c++");
   case BuiltinType::Half:
     Out << "Dh";
     break;
Index: lib/AST/ExprConstant.cpp
===================================================================
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -7320,6 +7320,9 @@
     case BuiltinType::ULong:
     case BuiltinType::ULongLong:
     case BuiltinType::UInt128:
+    case BuiltinType::UShortAccum:
+    case BuiltinType::UAccum:
+    case BuiltinType::ULongAccum:
       return integer_type_class;
 
     case BuiltinType::NullPtr:
Index: lib/AST/ASTContext.cpp
===================================================================
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1133,6 +1133,14 @@
   // C11 extension ISO/IEC TS 18661-3
   InitBuiltinType(Float16Ty,           BuiltinType::Float16);
 
+  // ISO/IEC JTC1 SC22 WG14 N1169 Extension
+  InitBuiltinType(ShortAccumTy, BuiltinType::ShortAccum);
+  InitBuiltinType(AccumTy, BuiltinType::Accum);
+  InitBuiltinType(LongAccumTy, BuiltinType::LongAccum);
+  InitBuiltinType(UnsignedShortAccumTy, BuiltinType::UShortAccum);
+  InitBuiltinType(UnsignedAccumTy, BuiltinType::UAccum);
+  InitBuiltinType(UnsignedLongAccumTy, BuiltinType::ULongAccum);
+
   // GNU extension, 128-bit integers.
   InitBuiltinType(Int128Ty,            BuiltinType::Int128);
   InitBuiltinType(UnsignedInt128Ty,    BuiltinType::UInt128);
@@ -1757,16 +1765,22 @@
       break;
     case BuiltinType::UShort:
     case BuiltinType::Short:
+    case BuiltinType::ShortAccum:
+    case BuiltinType::UShortAccum:
       Width = Target->getShortWidth();
       Align = Target->getShortAlign();
       break;
     case BuiltinType::UInt:
     case BuiltinType::Int:
+    case BuiltinType::Accum:
+    case BuiltinType::UAccum:
       Width = Target->getIntWidth();
       Align = Target->getIntAlign();
       break;
     case BuiltinType::ULong:
     case BuiltinType::Long:
+    case BuiltinType::LongAccum:
+    case BuiltinType::ULongAccum:
       Width = Target->getLongWidth();
       Align = Target->getLongAlign();
       break;
@@ -6238,7 +6252,15 @@
     case BuiltinType::ObjCSel:
       llvm_unreachable("@encoding ObjC primitive type");
 
-    // OpenCL and placeholder types don't need @encodings.
+    case BuiltinType::ShortAccum:
+    case BuiltinType::Accum:
+    case BuiltinType::LongAccum:
+    case BuiltinType::UShortAccum:
+    case BuiltinType::UAccum:
+    case BuiltinType::ULongAccum:
+      llvm_unreachable("No ObjC encoding for fixed point types");
+
+      // OpenCL and placeholder types don't need @encodings.
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
     case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
Index: include/clang/Serialization/ASTBitCodes.h
===================================================================
--- include/clang/Serialization/ASTBitCodes.h
+++ include/clang/Serialization/ASTBitCodes.h
@@ -802,106 +802,106 @@
     /// by the AST context when it is created.
     enum PredefinedTypeIDs {
       /// \brief The NULL type.
-      PREDEF_TYPE_NULL_ID       = 0,
+      PREDEF_TYPE_NULL_ID = 0,
 
       /// \brief The void type.
-      PREDEF_TYPE_VOID_ID       = 1,
+      PREDEF_TYPE_VOID_ID = 1,
 
       /// \brief The 'bool' or '_Bool' type.
-      PREDEF_TYPE_BOOL_ID       = 2,
+      PREDEF_TYPE_BOOL_ID = 2,
 
       /// \brief The 'char' type, when it is unsigned.
-      PREDEF_TYPE_CHAR_U_ID     = 3,
+      PREDEF_TYPE_CHAR_U_ID = 3,
 
       /// \brief The 'unsigned char' type.
-      PREDEF_TYPE_UCHAR_ID      = 4,
+      PREDEF_TYPE_UCHAR_ID = 4,
 
       /// \brief The 'unsigned short' type.
-      PREDEF_TYPE_USHORT_ID     = 5,
+      PREDEF_TYPE_USHORT_ID = 5,
 
       /// \brief The 'unsigned int' type.
-      PREDEF_TYPE_UINT_ID       = 6,
+      PREDEF_TYPE_UINT_ID = 6,
 
       /// \brief The 'unsigned long' type.
-      PREDEF_TYPE_ULONG_ID      = 7,
+      PREDEF_TYPE_ULONG_ID = 7,
 
       /// \brief The 'unsigned long long' type.
-      PREDEF_TYPE_ULONGLONG_ID  = 8,
+      PREDEF_TYPE_ULONGLONG_ID = 8,
 
       /// \brief The 'char' type, when it is signed.
-      PREDEF_TYPE_CHAR_S_ID     = 9,
+      PREDEF_TYPE_CHAR_S_ID = 9,
 
       /// \brief The 'signed char' type.
-      PREDEF_TYPE_SCHAR_ID      = 10,
+      PREDEF_TYPE_SCHAR_ID = 10,
 
       /// \brief The C++ 'wchar_t' type.
-      PREDEF_TYPE_WCHAR_ID      = 11,
+      PREDEF_TYPE_WCHAR_ID = 11,
 
       /// \brief The (signed) 'short' type.
-      PREDEF_TYPE_SHORT_ID      = 12,
+      PREDEF_TYPE_SHORT_ID = 12,
 
       /// \brief The (signed) 'int' type.
-      PREDEF_TYPE_INT_ID        = 13,
+      PREDEF_TYPE_INT_ID = 13,
 
       /// \brief The (signed) 'long' type.
-      PREDEF_TYPE_LONG_ID       = 14,
+      PREDEF_TYPE_LONG_ID = 14,
 
       /// \brief The (signed) 'long long' type.
-      PREDEF_TYPE_LONGLONG_ID   = 15,
+      PREDEF_TYPE_LONGLONG_ID = 15,
 
       /// \brief The 'float' type.
-      PREDEF_TYPE_FLOAT_ID      = 16,
+      PREDEF_TYPE_FLOAT_ID = 16,
 
       /// \brief The 'double' type.
-      PREDEF_TYPE_DOUBLE_ID     = 17,
+      PREDEF_TYPE_DOUBLE_ID = 17,
 
       /// \brief The 'long double' type.
       PREDEF_TYPE_LONGDOUBLE_ID = 18,
 
       /// \brief The placeholder type for overloaded function sets.
-      PREDEF_TYPE_OVERLOAD_ID   = 19,
+      PREDEF_TYPE_OVERLOAD_ID = 19,
 
       /// \brief The placeholder type for dependent types.
-      PREDEF_TYPE_DEPENDENT_ID  = 20,
+      PREDEF_TYPE_DEPENDENT_ID = 20,
 
       /// \brief The '__uint128_t' type.
-      PREDEF_TYPE_UINT128_ID    = 21,
+      PREDEF_TYPE_UINT128_ID = 21,
 
       /// \brief The '__int128_t' type.
-      PREDEF_TYPE_INT128_ID     = 22,
+      PREDEF_TYPE_INT128_ID = 22,
 
       /// \brief The type of 'nullptr'.
-      PREDEF_TYPE_NULLPTR_ID    = 23,
+      PREDEF_TYPE_NULLPTR_ID = 23,
 
       /// \brief The C++ 'char16_t' type.
-      PREDEF_TYPE_CHAR16_ID     = 24,
+      PREDEF_TYPE_CHAR16_ID = 24,
 
       /// \brief The C++ 'char32_t' type.
-      PREDEF_TYPE_CHAR32_ID     = 25,
+      PREDEF_TYPE_CHAR32_ID = 25,
 
       /// \brief The ObjC 'id' type.
-      PREDEF_TYPE_OBJC_ID       = 26,
+      PREDEF_TYPE_OBJC_ID = 26,
 
       /// \brief The ObjC 'Class' type.
-      PREDEF_TYPE_OBJC_CLASS    = 27,
+      PREDEF_TYPE_OBJC_CLASS = 27,
 
       /// \brief The ObjC 'SEL' type.
-      PREDEF_TYPE_OBJC_SEL      = 28,
+      PREDEF_TYPE_OBJC_SEL = 28,
 
       /// \brief The 'unknown any' placeholder type.
-      PREDEF_TYPE_UNKNOWN_ANY   = 29,
+      PREDEF_TYPE_UNKNOWN_ANY = 29,
 
       /// \brief The placeholder type for bound member functions.
-      PREDEF_TYPE_BOUND_MEMBER  = 30,
+      PREDEF_TYPE_BOUND_MEMBER = 30,
 
       /// \brief The "auto" deduction type.
-      PREDEF_TYPE_AUTO_DEDUCT   = 31,
+      PREDEF_TYPE_AUTO_DEDUCT = 31,
 
       /// \brief The "auto &&" deduction type.
       PREDEF_TYPE_AUTO_RREF_DEDUCT = 32,
 
       /// \brief The OpenCL 'half' / ARM NEON __fp16 type.
-      PREDEF_TYPE_HALF_ID       = 33,
+      PREDEF_TYPE_HALF_ID = 33,
 
       /// \brief ARC's unbridged-cast placeholder type.
       PREDEF_TYPE_ARC_UNBRIDGED_CAST = 34,
@@ -913,16 +913,16 @@
       PREDEF_TYPE_BUILTIN_FN = 36,
 
       /// \brief OpenCL event type.
-      PREDEF_TYPE_EVENT_ID      = 37,
+      PREDEF_TYPE_EVENT_ID = 37,
 
       /// \brief OpenCL clk event type.
-      PREDEF_TYPE_CLK_EVENT_ID  = 38,
+      PREDEF_TYPE_CLK_EVENT_ID = 38,
 
       /// \brief OpenCL sampler type.
-      PREDEF_TYPE_SAMPLER_ID    = 39,
+      PREDEF_TYPE_SAMPLER_ID = 39,
 
       /// \brief OpenCL queue type.
-      PREDEF_TYPE_QUEUE_ID      = 40,
+      PREDEF_TYPE_QUEUE_ID = 40,
 
       /// \brief OpenCL reserve_id type.
       PREDEF_TYPE_RESERVE_ID_ID = 41,
@@ -936,7 +936,25 @@
       /// \brief The '_Float16' type
       PREDEF_TYPE_FLOAT16_ID = 44,
 
-      /// \brief OpenCL image types with auto numeration
+      /// \brief The 'short _Accum' type
+      PREDEF_TYPE_SHORT_ACCUM_ID = 45,
+
+      /// \brief The '_Accum' type
+      PREDEF_TYPE_ACCUM_ID = 46,
+
+      /// \brief The 'long _Accum' type
+      PREDEF_TYPE_LONG_ACCUM_ID = 47,
+
+      /// \brief The 'unsigned short _Accum' type
+      PREDEF_TYPE_USHORT_ACCUM_ID = 48,
+
+      /// \brief The 'unsigned _Accum' type
+      PREDEF_TYPE_UACCUM_ID = 49,
+
+      /// \brief The 'unsigned long _Accum' type
+      PREDEF_TYPE_ULONG_ACCUM_ID = 50,
+
+    /// \brief OpenCL image types with auto numeration
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
       PREDEF_TYPE_##Id##_ID,
 #include "clang/Basic/OpenCLImageTypes.def"
Index: include/clang/Sema/DeclSpec.h
===================================================================
--- include/clang/Sema/DeclSpec.h
+++ include/clang/Sema/DeclSpec.h
@@ -281,6 +281,7 @@
   static const TST TST_float = clang::TST_float;
   static const TST TST_double = clang::TST_double;
   static const TST TST_float16 = clang::TST_Float16;
+  static const TST TST_accum = clang::TST_Accum;
   static const TST TST_float128 = clang::TST_float128;
   static const TST TST_bool = clang::TST_bool;
   static const TST TST_decimal32 = clang::TST_decimal32;
Index: include/clang/Basic/TokenKinds.def
===================================================================
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -383,6 +383,9 @@
 // C11 Extension
 KEYWORD(_Float16                    , KEYALL)
 
+// ISO/IEC JTC1 SC22 WG14 N1169 Extension
+KEYWORD(_Accum                      , KEYALL)
+
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32                  , KEYALL)
 KEYWORD(_Decimal64                  , KEYALL)
Index: include/clang/Basic/Specifiers.h
===================================================================
--- include/clang/Basic/Specifiers.h
+++ include/clang/Basic/Specifiers.h
@@ -46,26 +46,27 @@
     TST_unspecified,
     TST_void,
     TST_char,
-    TST_wchar,        // C++ wchar_t
-    TST_char16,       // C++11 char16_t
-    TST_char32,       // C++11 char32_t
+    TST_wchar,   // C++ wchar_t
+    TST_char16,  // C++11 char16_t
+    TST_char32,  // C++11 char32_t
     TST_int,
     TST_int128,
-    TST_half,         // OpenCL half, ARM NEON __fp16
-    TST_Float16,      // C11 extension ISO/IEC TS 18661-3
+    TST_half,     // OpenCL half, ARM NEON __fp16
+    TST_Float16,  // C11 extension ISO/IEC TS 18661-3
+    TST_Accum,    // ISO/IEC JTC1 SC22 WG14 N1169 Extension
     TST_float,
     TST_double,
     TST_float128,
-    TST_bool,         // _Bool
-    TST_decimal32,    // _Decimal32
-    TST_decimal64,    // _Decimal64
-    TST_decimal128,   // _Decimal128
+    TST_bool,        // _Bool
+    TST_decimal32,   // _Decimal32
+    TST_decimal64,   // _Decimal64
+    TST_decimal128,  // _Decimal128
     TST_enum,
     TST_union,
     TST_struct,
-    TST_class,        // C++ class type
-    TST_interface,    // C++ (Microsoft-specific) __interface type
-    TST_typename,     // Typedef, C++ class-name or enum name, etc.
+    TST_class,      // C++ class type
+    TST_interface,  // C++ (Microsoft-specific) __interface type
+    TST_typename,   // Typedef, C++ class-name or enum name, etc.
     TST_typeofType,
     TST_typeofExpr,
     TST_decltype,         // C++11 decltype
@@ -77,7 +78,7 @@
     TST_atomic,           // C11 _Atomic
 #define GENERIC_IMAGE_TYPE(ImgType, Id) TST_##ImgType##_t, // OpenCL image types
 #include "clang/Basic/OpenCLImageTypes.def"
-    TST_error // erroneous type
+    TST_error  // erroneous type
   };
 
   /// \brief Structure that packs information about the type specifiers that
Index: include/clang/Basic/DiagnosticCommonKinds.td
===================================================================
--- include/clang/Basic/DiagnosticCommonKinds.td
+++ include/clang/Basic/DiagnosticCommonKinds.td
@@ -168,6 +168,8 @@
                           InGroup<GccCompat>;
 def ext_clang_diagnose_if : Extension<"'diagnose_if' is a clang extension">,
                             InGroup<GccCompat>;
+def err_fixed_point_only_allowed_in_c : Error<
+  "Fixed point types are only allowed in C">;
 
 // SEH
 def err_seh_expected_handler : Error<
Index: include/clang/AST/BuiltinTypes.def
===================================================================
--- include/clang/AST/BuiltinTypes.def
+++ include/clang/AST/BuiltinTypes.def
@@ -119,6 +119,26 @@
 // '__int128_t'
 SIGNED_TYPE(Int128, Int128Ty)
 
+//===- Fixed point types --------------------------------------------------===//
+
+// 'short _Accum'
+SIGNED_TYPE(ShortAccum, ShortAccumTy)
+
+// '_Accum'
+SIGNED_TYPE(Accum, AccumTy)
+
+// 'long _Accum'
+SIGNED_TYPE(LongAccum, LongAccumTy)
+
+// 'unsigned short _Accum'
+UNSIGNED_TYPE(UShortAccum, UnsignedShortAccumTy)
+
+// 'unsigned _Accum'
+UNSIGNED_TYPE(UAccum, UnsignedAccumTy)
+
+// 'unsigned long _Accum'
+UNSIGNED_TYPE(ULongAccum, UnsignedLongAccumTy)
+
 //===- Floating point types -----------------------------------------------===//
 
 // 'half' in OpenCL, '__fp16' in ARM NEON.
Index: include/clang/AST/ASTContext.h
===================================================================
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1005,6 +1005,9 @@
   CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy;
   CanQualType UnsignedLongLongTy, UnsignedInt128Ty;
   CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty;
+  CanQualType ShortAccumTy, AccumTy,
+      LongAccumTy;  // ISO/IEC JTC1 SC22 WG14 N1169 Extension
+  CanQualType UnsignedShortAccumTy, UnsignedAccumTy, UnsignedLongAccumTy;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
   CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
Index: include/clang-c/Index.h
===================================================================
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -3174,8 +3174,14 @@
   CXType_Float128 = 30,
   CXType_Half = 31,
   CXType_Float16 = 32,
+  CXType_ShortAccum = 33,
+  CXType_Accum = 34,
+  CXType_LongAccum = 35,
+  CXType_UShortAccum = 36,
+  CXType_UAccum = 37,
+  CXType_ULongAccum = 38,
   CXType_FirstBuiltin = CXType_Void,
-  CXType_LastBuiltin  = CXType_Float16,
+  CXType_LastBuiltin = CXType_ULongAccum,
 
   CXType_Complex = 100,
   CXType_Pointer = 101,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to