[clang] Fixes: Can not use C99 function names as variable names in C89 (PR #129979)

A. Jiang via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 1 17:58:47 PDT 2025


================
@@ -135,6 +137,24 @@ bool Builtin::Context::isBuiltinFunc(llvm::StringRef FuncName) {
   return false;
 }
 
+static bool isSymbolAvailableInC89(const llvm::StringTable &Strings,
+                                   const Builtin::Info &BuiltinInfo) {
+
+  auto NameStr = Strings[BuiltinInfo.Offsets.Name];
+
+  if (NameStr.starts_with("__builtin_")) {
+    return true;
+  }
+
+  // FIXME: add other C89 symbols here
+  if (NameStr == "log" || NameStr == "va_start" || NameStr == "va_arg" ||
+      NameStr == "va_end") {
+    return true;
+  }
----------------
frederick-vs-ja wrote:

The list would be very long, see https://port70.net/~nsz/c/c89/c89-draft.html. Perhaps we should add a `.def` file for this.

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


More information about the cfe-commits mailing list