Add the __restrict__ keyword
PATCH v2 1/10 Add the __restrict__ keyword
---
Hi Chris,
I added a separate test file (alternate-keywords.c) which includes test cases for restrict, __restrict and __restrict__. I also included some additional tests for other alternative keywords (hence the name of the file), namely inline, typeof and their variants.
I have tested this only on 32-bit Linux so far. (I will do the other platforms tomorrow, but I don't expect to find any problems) I wanted to get this to you tonight.
ATB,
Ramsay Jones
ident-list.h | 2 +- parse.c | 3 ++- validation/alternate-keywords.c | 46 +++++++++++++++++++++++++++++++++++++++++ validation/reserved.c | 1 + 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 validation/alternate-keywords.c
ident-list.h +1 -1
@@ -86,7 +86,7 @@ IDENT(stdcall); IDENT(__stdcall__);IDENT (fastcall);IDENT (__fastcall__);IDENT (dllimport);IDENT (__dllimport__);IDENT (dllexport);IDENT (__dllexport__); -IDENT (restrict);IDENT (__restrict); +IDENT (restrict);IDENT (__restrict);IDENT (__restrict__);IDENT (artificial);IDENT (__artificial__);IDENT (leaf);IDENT (__leaf__);IDENT (vector_size);IDENT (__vector_size__);
parse.c +2 -1
@@ -435,6 +435,7 @@ static struct init_keyword {/* Ignored for now.. */ { "restrict", NS_TYPEDEF, .op = &restrict_op}, { "__restrict", NS_TYPEDEF, .op = &restrict_op}, + { "__restrict__", NS_TYPEDEF, .op = &restrict_op},/* Storage class */ { "auto", NS_TYPEDEF, .op = &auto_op },
@@ -1553,7 +1554,7 @@ static struct token *abstract_array_declarator(struct token *token, struct symbo token =abstract_array_static_declarator (token, &has_static); -if (match_idents (token, &restrict_ident, &__restrict_ident,NULL )) +if (match_idents (token, &restrict_ident, &__restrict_ident, &__restrict___ident,NULL )) token =abstract_array_static_declarator (token->next, &has_static); token =parse_expression (token, &expr); sym->array_size = expr;
validation/alternate-keywords.c new file +46 -0
46 lines not on this page · raw message
validation/reserved.c +1 -0
@@ -30,6 +30,7 @@ reserved.c:8:12: error: Trying to use reserved word '__const' as identifier reserved.c:9:12: error: Trying to use reserved word '__const__' as identifier reserved.c:10:12: error: Trying to use reserved word 'restrict' as identifier reserved.c:11:12: error: Trying to use reserved word '__restrict' as identifier +reserved.c:12:12: error: Trying to use reserved word '__restrict__' as identifier reserved.c:13:12: error: Trying to use reserved word 'typedef' as identifier reserved.c:14:12: error: Trying to use reserved word '__typeof' as identifier reserved.c:15:12: error: Trying to use reserved word '__typeof__' as identifier
Signature · 1 line
2.0.0
Christopher Li
maintainerCatching up my backlog.
Quoted 10 lines · Ramsay Jones
Signed-off-by Ramsay Jones <[email protected]>---
Hi Chris,
I added a separate test file (
alternate-keywords.c) which includes test cases for restrict,__restrictand__restrict__. I also included some additional tests for other alternative keywords (hence the name of the file), namely inline, typeof and their variants.
Looks good.
Quoted 3 lines
Just for the
record, I don't know of any use of__restrict__in an abstract array declaration on _any_ platform.
If there is no code using the __restrict__ for abstract array, we shouldn't need this line:
parse.c static struct token *abstract_array_declarator(struct token *token, struct symbo · line 1560
Quoted 9 lines
parse.c +1
-1@@ -1553,7 +1554,7 @@ static struct token *abstract_array_declarator(struct token *token, struct symbo token =abstract_array_static_declarator (token, &has_static); -if (match_idents (token, &restrict_ident, &__restrict_ident,NULL )) +if (match_idents (token, &restrict_ident, &__restrict_ident, &__restrict___ident,NULL )) token =abstract_array_static_declarator (token->next, &has_static); token =parse_expression (token, &expr); sym->array_size = expr;
Or, if you have valid reason to add it. Please provide a test case for this code path.
Thanks
Chris
Quoted 3 lines · Christopher Li
Catching up my backlog.
On Fri, Aug 8, 2014 at 4:11 AM, Ramsay Jones <[email protected]> wrote:
[...]
Quoted 6 lines
Quoted 3 lines
Just for the
record, I don't know of any use of__restrict__in an abstract array declaration on _any_ platform.If there is no code using the
__restrict__for abstract array, we shouldn't need this line:
Of course, just because I'm not aware of any such use, doesn't mean there isn't one. :-D
gcc supports this usage, so it would be useful if sparse did also.
Quoted 4 lines
Quoted 4 lines
parse.c +0
-0@@ -1553,7 +1554,7 @@ static struct token *abstract_array_declarator(struct token *token, struct symbo token =abstract_array_static_declarator (token, &has_static);
Quoted 8 lines
parse.c static struct token *abstract_array_declarator(struct token *token, struct symbo · line 1560
Quoted 5 lines
parse.c +1
-1-if (match_idents (token, &restrict_ident, &__restrict_ident,NULL )) +if (match_idents (token, &restrict_ident, &__restrict_ident, &__restrict___ident,NULL )) token =abstract_array_static_declarator (token->next, &has_static); token =parse_expression (token, &expr); sym->array_size = expr;Or, if you have valid reason to add it. Please provide a test case for this code path.
Yep, will do.
ATB,
Ramsay Jones