[clang-repl] Fix C89 incompatible keywords#189432
Merged
vgvassilev merged 1 commit intollvm:mainfrom Mar 30, 2026
Merged
Conversation
Member
|
@llvm/pr-subscribers-clang Author: Kerem Şahin (keremsahn) ChangesRestrict and inline keywords are removed from C89 interpreter since these keywords caused fail at runtime preamble. Links to #189088 @vgvassilev Full diff: https://github.com/llvm/llvm-project/pull/189432.diff 2 Files Affected:
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
|
Contributor
|
@vgvassilev can this added to the llvm 22 release branch, so that cppinterop can support the c89 flag for llvm 22? |
Contributor
|
/cherry-pick 8bd8304 |
Member
Error: Command failed due to missing milestone. |
Contributor
|
/cherry-pick 8bd8304 |
Member
|
/pull-request #189538 |
c-rhodes
pushed a commit
to llvmbot/llvm-project
that referenced
this pull request
Mar 31, 2026
Restrict and inline keywords are removed for C89 interpreter since these keywords caused fail at runtime preamble. Fixes llvm#189088 (cherry picked from commit 8bd8304)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restrict and inline keywords are removed for C89 interpreter since these keywords caused fail at runtime preamble.
Links to #189088
@vgvassilev