[PATCH] D112906: [PowerPC] Emit warning for ieeelongdouble on older GNU toolchain

Qiu Chaofan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 31 22:27:35 PDT 2021


qiucf created this revision.
qiucf added reviewers: PowerPC, jsji, nemanjai, shchenz.
Herald added a subscriber: kbarton.
qiucf requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112906

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/PPCLinux.cpp
  clang/lib/Driver/ToolChains/PPCLinux.h
  clang/test/Driver/ppc-float-abi-warning.cpp


Index: clang/test/Driver/ppc-float-abi-warning.cpp
===================================================================
--- /dev/null
+++ clang/test/Driver/ppc-float-abi-warning.cpp
@@ -0,0 +1,6 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang -### -x c++ -target powerpc64le-unknown-linux-gnu %s -mabi=ieeelongdouble
+
+// expected-warning{{float ABI 'ieeelongdouble' is not supported by current C++ stdlib}}
+
+long double foo(long double x) { return x; }
Index: clang/lib/Driver/ToolChains/PPCLinux.h
===================================================================
--- clang/lib/Driver/ToolChains/PPCLinux.h
+++ clang/lib/Driver/ToolChains/PPCLinux.h
@@ -18,8 +18,7 @@
 class LLVM_LIBRARY_VISIBILITY PPCLinuxToolChain : public Linux {
 public:
   PPCLinuxToolChain(const Driver &D, const llvm::Triple &Triple,
-                    const llvm::opt::ArgList &Args)
-      : Linux(D, Triple, Args) {}
+                    const llvm::opt::ArgList &Args);
 
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Index: clang/lib/Driver/ToolChains/PPCLinux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/PPCLinux.cpp
+++ clang/lib/Driver/ToolChains/PPCLinux.cpp
@@ -8,12 +8,28 @@
 
 #include "PPCLinux.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Support/Path.h"
 
 using namespace clang::driver::toolchains;
 using namespace llvm::opt;
 
+PPCLinuxToolChain::PPCLinuxToolChain(const Driver &D,
+                                     const llvm::Triple &Triple,
+                                     const llvm::opt::ArgList &Args)
+    : Linux(D, Triple, Args) {
+  if (D.CCCIsCXX() && (ToolChain::GetCXXStdlibType(Args) == CST_Libcxx ||
+                       GCCInstallation.getVersion().isOlderThan(11, 1, 0))) {
+    if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
+      StringRef ABIName = A->getValue();
+      if (ABIName != "ibmlongdouble") {
+        D.Diag(diag::warn_drv_unsupported_float_abi_by_cxxlib) << ABIName;
+      }
+    }
+  }
+}
+
 void PPCLinuxToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
                                                   ArgStringList &CC1Args) const {
   if (!DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) &&
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -358,6 +358,8 @@
   "argument '%0' is deprecated%select{|, use '%2' instead}1">, InGroup<Deprecated>;
 def warn_drv_assuming_mfloat_abi_is : Warning<
   "unknown platform, assuming -mfloat-abi=%0">;
+def warn_drv_unsupported_float_abi_by_cxxlib : Warning<
+  "float ABI '%0' is not supported by current C++ stdlib">;
 def warn_ignoring_ftabstop_value : Warning<
   "ignoring invalid -ftabstop value '%0', using default value %1">;
 def warn_drv_overriding_flag_option : Warning<


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112906.383716.patch
Type: text/x-patch
Size: 3082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211101/accdd050/attachment.bin>


More information about the cfe-commits mailing list