Disable _ExtInt by default
authorErich Keane <erich.keane@intel.com>
Wed, 29 Apr 2020 20:15:04 +0000 (13:15 -0700)
committerErich Keane <erich.keane@intel.com>
Wed, 29 Apr 2020 20:48:12 +0000 (13:48 -0700)
Since the _ExtInt type got into the repo, we've discovered that the ABI
implications weren't completely understood. The other architectures are
going to be audited (see D79118), however downstream targets aren't
going to benefit from this audit.

This patch disables the _ExtInt type by default and makes the
target-info an opt-in.  As it is audited, I'll re-enable these for all
of our default targets.

clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Targets/X86.h
clang/lib/Sema/SemaType.cpp
clang/test/Sema/ext-int-not-supported.c [new file with mode: 0644]

index ab47954..910a4d6 100644 (file)
@@ -547,6 +547,12 @@ public:
     return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt128;
   } // FIXME
 
+  /// Determine whether the _ExtInt type is supported on this target. This
+  /// limitation is put into place for ABI reasons.
+  virtual bool hasExtIntType() const {
+    return false;
+  }
+
   /// Determine whether _Float16 is supported on this target.
   virtual bool hasLegalHalfType() const { return HasLegalHalfType; }
 
index a68109a..39ccac9 100644 (file)
@@ -435,6 +435,8 @@ public:
   }
 
   ArrayRef<Builtin::Info> getTargetBuiltins() const override;
+
+  bool hasExtIntType() const override { return true; }
 };
 
 class LLVM_LIBRARY_VISIBILITY NetBSDI386TargetInfo
@@ -737,6 +739,8 @@ public:
   }
 
   ArrayRef<Builtin::Info> getTargetBuiltins() const override;
+
+  bool hasExtIntType() const override { return true; }
 };
 
 // x86-64 Windows target
index a96e1c1..338e335 100644 (file)
@@ -1443,6 +1443,9 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
     break;
   }
   case DeclSpec::TST_extint: {
+    if (!S.Context.getTargetInfo().hasExtIntType())
+      S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
+        << "_ExtInt";
     Result = S.BuildExtIntType(DS.getTypeSpecSign() == TSS_unsigned,
                                DS.getRepAsExpr(), DS.getBeginLoc());
     if (Result.isNull()) {
diff --git a/clang/test/Sema/ext-int-not-supported.c b/clang/test/Sema/ext-int-not-supported.c
new file mode 100644 (file)
index 0000000..23610b9
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify %s
+
+void foo() {
+  _ExtInt(33) a; // expected-error{{_ExtInt is not supported on this target}}
+}