https://bugs.llvm.org/show_bug.cgi?id=50342
Bug ID: 50342
Summary: Missing diagnostic for comma in constant expression
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangb...@nondot.org
Reporter: john.br...@arm.com
CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
richard-l...@metafoo.co.uk
In the C11 (and earlier) standard it says in section 6.6 about constant
expressions:
Constant expressions shall not contain assignment, increment, decrement,
function-call,
or comma operators, except when they are contained within a subexpression
that is not
evaluated.
Which means we should be giving a diagnostic for code like this
static const int i = 0 ? 2 : ((void)3, 4);
There's a comment in clang/lib/Sema/SemaDecl.cpp about this:
// FIXME: Need strict checking. In C89, we need to check for
// any assignment, increment, decrement, function-calls, or
// commas outside of a sizeof. In C99, it's the same list,
// except that the aforementioned are allowed in unevaluated
// expressions. Everything else falls under the
// "may accept other forms of constant expressions" exception.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs