-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[C23] Add __builtin_c23_va_start #131166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AaronBallman
merged 8 commits into
llvm:main
from
AaronBallman:aballman-builtin-c23-va-start
Mar 15, 2025
Merged
[C23] Add __builtin_c23_va_start #131166
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
92e26f7
[C23] Add __builtin_c23_va_start
AaronBallman 533db29
Add documentation
AaronBallman fbcf4d6
Update based on review feedback
AaronBallman 0d958db
Fixes based on review feedback
AaronBallman 55c5dbc
Same great builtin, but now with more codegen!
AaronBallman 7a25c55
Add pre-C23 compatibility diagnostic
AaronBallman 065fa19
Merge remote-tracking branch 'origin/main' into aballman-builtin-c23-…
AaronBallman 475a112
Fix tests for new diagnostic wording on main
AaronBallman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// RUN: %clang_cc1 -std=c23 -fsyntax-only -ffreestanding -verify=expected,both %s -triple i386-pc-unknown | ||
// RUN: %clang_cc1 -std=c23 -fsyntax-only -ffreestanding -verify=expected,both %s -triple x86_64-apple-darwin9 | ||
// RUN: %clang_cc1 -std=c23 -fsyntax-only -ffreestanding -fms-compatibility -verify=expected,both %s -triple x86_64-pc-win32 | ||
// RUN: %clang_cc1 -std=c17 -fsyntax-only -ffreestanding -verify=both,pre-c23 %s | ||
|
||
void foo(int x, int y, ...) { | ||
__builtin_va_list list; | ||
__builtin_c23_va_start(); // pre-c23-error {{use of unknown builtin '__builtin_c23_va_start'}} \ | ||
expected-error{{too few arguments to function call, expected 1, have 0}} | ||
// Note, the unknown builtin diagnostic is only issued once per function, | ||
// which is why the rest of the lines do not get the same diagonstic. | ||
__builtin_c23_va_start(list); // ok | ||
__builtin_c23_va_start(list, 0); // expected-warning {{second argument to 'va_start' is not the last non-variadic parameter}} | ||
__builtin_c23_va_start(list, x); // expected-warning {{second argument to 'va_start' is not the last non-variadic parameter}} | ||
__builtin_c23_va_start(list, y); // ok | ||
__builtin_c23_va_start(list, 0, 1); // expected-error {{too many arguments to function call, expected at most 2, have 3}} | ||
__builtin_c23_va_start(list, y, y); // expected-error {{too many arguments to function call, expected at most 2, have 3}} | ||
} | ||
|
||
// Test the same thing as above, only with the macro from stdarg.h. This will | ||
// not have the unknown builtin diagnostics, but will have different | ||
// diagnostics between C23 and earlier modes. | ||
#include <stdarg.h> | ||
erichkeane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
void bar(int x, int y, ...) { | ||
// FIXME: the "use of undeclared identifier 'va_start'" diagnostics is an odd | ||
// follow-on diagnostic that should be silenced. | ||
va_list list; | ||
va_start(); // pre-c23-error {{too few arguments provided to function-like macro invocation}} \ | ||
pre-c23-error {{use of undeclared identifier 'va_start'}} \ | ||
expected-error{{too few arguments to function call, expected 1, have 0}} | ||
va_start(list); // pre-c23-error {{too few arguments provided to function-like macro invocation}} \ | ||
pre-c23-error {{use of undeclared identifier 'va_start'}} | ||
va_start(list, 0); // both-warning {{second argument to 'va_start' is not the last non-variadic parameter}} | ||
va_start(list, x); // both-warning {{second argument to 'va_start' is not the last non-variadic parameter}} | ||
va_start(list, y); // ok | ||
va_start(list, 0, 1); // pre-c23-error {{too many arguments provided to function-like macro invocation}} \ | ||
pre-c23-error {{use of undeclared identifier 'va_start'}} \ | ||
expected-error {{too many arguments to function call, expected at most 2, have 3}} | ||
va_start(list, y, y); // pre-c23-error {{too many arguments provided to function-like macro invocation}} \ | ||
pre-c23-error {{use of undeclared identifier 'va_start'}} \ | ||
expected-error {{too many arguments to function call, expected at most 2, have 3}} | ||
// pre-c23-note@__stdarg_va_arg.h:* 4 {{macro 'va_start' defined here}} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.