[clang] [clang][Driver][AVR] Reject c/c++ compilation for avr1 devices (PR #111798)

Ben Shi via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 11 18:30:05 PDT 2024


================
@@ -400,6 +400,14 @@ void AVRToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
 void AVRToolChain::addClangTargetOptions(
     const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
     Action::OffloadKind DeviceOffloadKind) const {
+  // Reject C/C++ compilation for avr1 devices.
+  const Driver &D = getDriver();
+  std::string CPU = getCPUName(D, DriverArgs, getTriple());
+  std::optional<StringRef> FamilyName = GetMCUFamilyName(CPU);
+  if (CPU == "avr1" || (FamilyName && FamilyName->compare("avr1") == 0))
+    D.Diag(diag::err_drv_opt_unsupported_input_type) << "avr1"
+                                                     << "c/c++";
----------------
benshi001 wrote:

Since `-mmcu` is the only way to trigger this issue, I have updated my error message to `'-mmcu=attiny11' invalid for input of type c/c++`

https://github.com/llvm/llvm-project/pull/111798


More information about the cfe-commits mailing list