forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C23] Complete support for WG14 N2508 (llvm#71398)
In Clang 16, we implemented the ability to add a label at the end of a compound statement. These changes complete the implementation by allowing a label to be followed by a declaration in C. Note, this seems to have fixed an issue with some OpenMP stand-alone directives not being properly diagnosed as per: https://www.openmp.org/spec-html/5.1/openmpsu19.html#x34-330002.1.3 (The same requirement exists in OpenMP 5.2 as well.)
- Loading branch information
1 parent
37fa327
commit 8bd06d5
Showing
17 changed files
with
151 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -1,23 +1,50 @@ | ||
// RUN: %clang_cc1 -verify -std=c2x %s | ||
// RUN: %clang_cc1 -verify -std=c23 %s | ||
// RUN: %clang_cc1 -verify=pedantic -std=c11 -pedantic %s | ||
// RUN: %clang_cc1 -verify=compat -std=c23 -Wpre-c23-compat %s | ||
|
||
// expected-no-diagnostics | ||
|
||
/* WG14 N2508: yes | ||
* Free positioning of labels inside compound statements | ||
*/ | ||
void test() { | ||
void test(void) { | ||
{ | ||
inner: | ||
} | ||
} /* pedantic-warning {{label at end of compound statement is a C23 extension}} | ||
compat-warning {{label at end of compound statement is incompatible with C standards before C23}} | ||
*/ | ||
|
||
switch (1) { | ||
case 1: | ||
} | ||
} /* pedantic-warning {{label at end of compound statement is a C23 extension}} | ||
compat-warning {{label at end of compound statement is incompatible with C standards before C23}} | ||
*/ | ||
|
||
{ | ||
multiple: labels: on: a: line: | ||
} | ||
} /* pedantic-warning {{label at end of compound statement is a C23 extension}} | ||
compat-warning {{label at end of compound statement is incompatible with C standards before C23}} | ||
*/ | ||
|
||
final: | ||
} | ||
} /* pedantic-warning {{label at end of compound statement is a C23 extension}} | ||
compat-warning {{label at end of compound statement is incompatible with C standards before C23}} | ||
*/ | ||
|
||
void test_labels(void) { | ||
label: | ||
int i = 0; /* pedantic-warning {{label followed by a declaration is a C23 extension}} | ||
compat-warning {{label followed by a declaration is incompatible with C standards before C23}} | ||
*/ | ||
|
||
switch (i) { | ||
case 1: | ||
_Static_assert(1, ""); /* pedantic-warning {{label followed by a declaration is a C23 extension}} | ||
compat-warning {{label followed by a declaration is incompatible with C standards before C23}} | ||
*/ | ||
default: | ||
_Static_assert(1, ""); /* pedantic-warning {{label followed by a declaration is a C23 extension}} | ||
compat-warning {{label followed by a declaration is incompatible with C standards before C23}} | ||
*/ | ||
} | ||
} |
This file contains 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 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 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 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
Oops, something went wrong.