[llvm-branch-commits] [clang] release/22.x: [clang-repl] Fix C89 incompatible keywords (#189432) (PR #189538)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Mar 30 22:52:20 PDT 2026


https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/189538

Backport 8bd83048084c27615e9536227fbb2545472915e7

Requested by: @vgvassilev

>From 6a0f4ce088ef7b8c4adc9021a508ec30f0ebd863 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kerem=20=C5=9Eahin?= <keremsahin401 at gmail.com>
Date: Mon, 30 Mar 2026 21:14:52 +0300
Subject: [PATCH] [clang-repl] Fix C89 incompatible keywords (#189432)

Restrict and inline keywords are removed for C89 interpreter since these
keywords caused fail at runtime preamble.

Fixes #189088

(cherry picked from commit 8bd83048084c27615e9536227fbb2545472915e7)
---
 clang/lib/Interpreter/Interpreter.cpp | 11 +++++++++--
 clang/test/Interpreter/pretty-print.c |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index 9c94cfa5ee381..2684a00ce5f07 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -337,9 +337,16 @@ const char *const Runtimes = R"(
       __clang_Interpreter_SetValueCopyArr(Src[0], Placement, Size);
     }
 #else
+    #if __STDC_VERSION__ < 199901L
+      #define CI_RESTRICT
+      #define CI_INLINE
+    #else
+      #define CI_RESTRICT restrict
+      #define CI_INLINE inline
+    #endif
     #define EXTERN_C extern
-    EXTERN_C void *memcpy(void *restrict dst, const void *restrict src, __SIZE_TYPE__ n);
-    EXTERN_C inline void __clang_Interpreter_SetValueCopyArr(const void* Src, void* Placement, unsigned long Size) {
+    EXTERN_C void *memcpy(void *CI_RESTRICT dst, const void *CI_RESTRICT src, __SIZE_TYPE__ n);
+    EXTERN_C CI_INLINE void __clang_Interpreter_SetValueCopyArr(const void* Src, void* Placement, unsigned long Size) {
       memcpy(Placement, Src, Size);
     }
 #endif // __cplusplus
diff --git a/clang/test/Interpreter/pretty-print.c b/clang/test/Interpreter/pretty-print.c
index b8058a762897e..9be13855eafe8 100644
--- a/clang/test/Interpreter/pretty-print.c
+++ b/clang/test/Interpreter/pretty-print.c
@@ -1,6 +1,7 @@
 // REQUIRES: host-supports-jit
 // RUN: cat %s | clang-repl -Xcc -xc  | FileCheck %s
 // RUN: cat %s | clang-repl -Xcc -std=c++11 | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -xc -Xcc -std=c89 | FileCheck %s
 
 // UNSUPPORTED: hwasan, msan
 



More information about the llvm-branch-commits mailing list