-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
delay 'empty character constant' warning to phase 5
A subset of C syntax regarding character constants is: char-constant: ' c-char-sequence ' c-char-sequence: char c-char-sequence char In short, when tokenized, a character constant must have at least one character between the quotes. Consequently, sparse will issue an error on empty character constants (unlike GCC). However, sparse issues the error during tokenization (phase 3), before preprocessing directives are handled (phase 4). This means that code like: #if 0 ... '' #endif will throw an error although the corresponding code is discarded. Fix this by 1) silently accept empty char constants during tokenization 2) issue the diagnostic only when escape sequences are handled. Signed-off-by: Luc Van Oostenryck <[email protected]>
- Loading branch information
Showing
4 changed files
with
28 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
static int a = ''; | ||
|
||
/* | ||
* check-name: empty-char-constant | ||
* | ||
* check-error-start | ||
empty-char-constant.c:1:16: error: empty character constant | ||
* check-error-end | ||
*/ |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#if 0 | ||
'' | ||
#endif | ||
|
||
/* | ||
* check-name: empty-char-constant | ||
* check-command: sparse -E $file | ||
* | ||
* check-output-start | ||
* check-output-end | ||
*/ |