Skip to content

Commit b6b0257

Browse files
authored
Fix the signature for __builtin___clear_cache (#134376)
The signature was changed from void(char *, char *) to void(void *, void *) to match GCC's signature for the same builtin. Fixes #47833
1 parent d9bf390 commit b6b0257

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ Bug Fixes to Compiler Builtins
354354

355355
- The behvaiour of ``__add_pointer`` and ``__remove_pointer`` for Objective-C++'s ``id`` and interfaces has been fixed.
356356

357+
- The signature for ``__builtin___clear_cache`` was changed from
358+
``void(char *, char *)`` to ``void(void *, void *)`` to match GCC's signature
359+
for the same builtin. (#GH47833)
360+
357361
Bug Fixes to Attribute Support
358362
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
359363
- Fixed crash when a parameter to the ``clang::annotate`` attribute evaluates to ``void``. See #GH119125

clang/include/clang/Basic/Builtins.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ def FrameAddress : Builtin {
920920
def ClearCache : Builtin {
921921
let Spellings = ["__builtin___clear_cache"];
922922
let Attributes = [NoThrow];
923-
let Prototype = "void(char*, char*)";
923+
let Prototype = "void(void*, void*)";
924924
}
925925

926926
def BuiltinSetjmp : Builtin {

clang/test/Sema/clear_cache.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s
2+
3+
// Ensure that __builtin___clear_cache has the expected signature. Clang used
4+
// to have a signature accepting char * while GCC had a signature accepting
5+
// void * that was documented incorrectly.
6+
void test(void) {
7+
int n = 0;
8+
__builtin___clear_cache(&n, &n + 1); // Ok
9+
10+
__builtin___clear_cache((const void *)&n, (const void *)(&n + 1)); // expected-warning 2 {{passing 'const void *' to parameter of type 'void *' discards qualifiers}}
11+
}
12+

0 commit comments

Comments
 (0)