diff options
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r-- | clang/lib/AST/Expr.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 818b60ca50b..21e668f68ff 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -3021,6 +3021,13 @@ bool Expr::HasSideEffects(const ASTContext &Ctx, case CXXReinterpretCastExprClass: case CXXConstCastExprClass: case CXXFunctionalCastExprClass: { + // While volatile reads are side-effecting in both C and C++, we treat them + // as having possible (not definite) side-effects. This allows idiomatic + // code to behave without warning, such as sizeof(*v) for a volatile- + // qualified pointer. + if (!IncludePossibleEffects) + break; + const CastExpr *CE = cast<CastExpr>(this); if (CE->getCastKind() == CK_LValueToRValue && CE->getSubExpr()->getType().isVolatileQualified()) |