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

David Spickett via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 11 06:19:38 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++";
----------------
DavidSpickett wrote:

The error is certainly the right category, but it's a shame you can't have it say "device family 'avr1'" (replace "device family" with whatever the correct term is).

I looked around and I don't see a way to use an existing error but prepend to the text. Only other way is to make a whole new error type which seems a shame when this is so close. Not that big of a deal, but it would help new users I think.

@Sirraide you helped me on diagnostics before, is it plausible to do that or is a new error type the only way?

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


More information about the cfe-commits mailing list