Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ C Language Changes

C2y Feature Support
^^^^^^^^^^^^^^^^^^^
- No longer triggering ``-Wstatic-in-inline`` in C2y mode; use of a static
function or variable within an extern inline function is no longer a
constraint per `WG14 N3622 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3622.txt>`_.
- Clang now supports `N3355 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm>`_ Named Loops.

C23 Feature Support
Expand Down
6 changes: 5 additions & 1 deletion clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ static void diagnoseUseOfInternalDeclInInlineFunction(Sema &S,
// This is disabled under C++; there are too many ways for this to fire in
// contexts where the warning is a false positive, or where it is technically
// correct but benign.
if (S.getLangOpts().CPlusPlus)
//
// This is also disabled in C2y because of WG14 N3622 which removed the
// constraint entirely. It is left enabled in earlier language modes because
// this is a constraint in those language modes.
if (S.getLangOpts().CPlusPlus || S.getLangOpts().C2y)
return;

// Check if this is an inlined function or method.
Expand Down
20 changes: 20 additions & 0 deletions clang/test/C/C2y/n3622.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: %clang_cc1 -verify=good -pedantic -Wall -std=c2y %s
// RUN: %clang_cc1 -verify -pedantic -Wall -std=c23 %s
// RUN: %clang_cc1 -verify -pedantic -Wall -std=c17 %s
// good-no-diagnostics

/* WG14 N3622: Clang 22
* Allow calling static inline within extern inline
*
* This verifies that a constraint from previous standards is no longer
* triggered in C2y mode. The constraint is with calling a statric function
* or using a static variable from an inline function with external linkage.
*/

static void static_func(void) {} // expected-note {{declared here}}
static int static_var; // expected-note {{declared here}}

extern inline void test(void) {
static_func(); // expected-warning {{static function 'static_func' is used in an inline function with external linkage}}
static_var = 12; // expected-warning {{static variable 'static_var' is used in an inline function with external linkage}}
}
2 changes: 1 addition & 1 deletion clang/www/c_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ <h2 id="c2y">C2y implementation status</h2>
<tr>
<td>Allow calling static inline within extern inline</td>
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3622.txt">N3622</a></td>
<td class="unknown" align="center">Unknown</td>
<td class="unreleased" align="center">Clang 22</td>
</tr>
<tr>
<td>Generic replacement (v. 2 of quasi-literals)</td>
Expand Down
Loading