[PATCH] Allow C11 static assert declaration as clause-1 in for loops.
Rachel Craik
rcraik at ca.ibm.com
Mon Apr 20 10:45:04 PDT 2015
Hi rsmith, hfinkel,
According to the C11 standard, `_Static_assert` should be allowed as clause-1 in a for loop.
For example:
```
for (_Static_assert(1, "1 is nonzero");;) {}
```
The relevant section of the C11 grammar is:
//for ( declaration expressionopt ; expressionopt ) statement
declaration:
declaration-specifiers init-declarator-listopt ;
static_assert-declaration//
It is not allowed in C++11, where the for statement has the form:
//for ( for-init-statement conditionopt; expressionopt) statement//
and for-init-statement can only be an //expression-statement// or a //simple-declaration//, not a //static_assert-declaration//
http://reviews.llvm.org/D9113
Files:
include/clang/Parse/Parser.h
lib/Parse/ParseDeclCXX.cpp
lib/Parse/ParseStmt.cpp
lib/Sema/SemaStmt.cpp
test/Parser/static-assert.c
test/Parser/static-assert.cpp
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9113.24026.patch
Type: text/x-patch
Size: 4745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150420/33f988a5/attachment.bin>
More information about the cfe-commits
mailing list