Commit Graph

5 Commits

Author SHA1 Message Date
Richard Smith e3dbfe04b7 Teach -Wunsequenced that the side-effects of a function evaluation are sequenced
before the value computation of the result. In C, this is implied by there being
a sequence point after their evaluation, and in C++, it's implied by the
side-effects being sequenced before the expressions and statements in the
function body.

llvm-svn: 185282
2013-06-30 10:40:20 +00:00
Richard Smith 83e37bee44 PR16467: Teach -Wunsequenced that in C11 (unlike C++11), an assignment's
side-effect is not sequenced before its value computation. Also fix a
mishandling of ?: expressions where the condition is constant that was
exposed by the tests for this.

llvm-svn: 185035
2013-06-26 23:16:51 +00:00
Richard Smith 5011a0022a Some builtins do not evaluate their arguments. Teach EvaluatedExprVisitor not
to visit them.

llvm-svn: 172769
2013-01-17 23:46:04 +00:00
Richard Smith 01a7fba820 -Wunsequenced: if the LHS of an &&, || or ?: is not constant, check for
unsequenced operations in the RHS. We don't compare the RHS with the rest of
the expression yet; such checks will need care to avoid diagnosing unsequenced
operations which are both in conditionally-evaluated subexpressions which
actually can't occur together, such as in '(b && ++x) + (!b && ++x)'.

llvm-svn: 172760
2013-01-17 22:06:26 +00:00
Richard Smith c406cb7364 Add -Wunsequenced (with compatibility alias -Wsequence-point) to warn on
expressions which have undefined behavior due to multiple unsequenced
modifications or an unsequenced modification and use of a variable.

llvm-svn: 172690
2013-01-17 01:17:56 +00:00