diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2015-01-03 17:00:12 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2015-01-03 17:00:12 +0000 |
| commit | 409af508589990413231e9ac567db1289de1b18c (patch) | |
| tree | 6920721e1eaa3ddf3dac9762ad923d0989461406 /clang/test/SemaCXX/warn-unused-value.cpp | |
| parent | d73bfba7ebc915214c93e93652eac8685c005262 (diff) | |
| download | bcm5719-llvm-409af508589990413231e9ac567db1289de1b18c.tar.gz bcm5719-llvm-409af508589990413231e9ac567db1289de1b18c.zip | |
Volatile reads are side-effecting operations, but in the general case of access through a volatile-qualified type, we're not certain of the underlying object's side-effects on access.
Treat volatile accesses as "maybe" instead of "definite" side effects for the purposes of warning on evaluations in an unevaluated context. No longer diagnose on idiomatic code like:
int * volatile v;
(void)sizeof(*v);
llvm-svn: 225116
Diffstat (limited to 'clang/test/SemaCXX/warn-unused-value.cpp')
| -rw-r--r-- | clang/test/SemaCXX/warn-unused-value.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/test/SemaCXX/warn-unused-value.cpp b/clang/test/SemaCXX/warn-unused-value.cpp index 3be2844aba7..efabd506306 100644 --- a/clang/test/SemaCXX/warn-unused-value.cpp +++ b/clang/test/SemaCXX/warn-unused-value.cpp @@ -90,9 +90,10 @@ void f() { Bad b; (void)typeid(b.f()); // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}} - // A dereference of a volatile pointer is a side effecting operation, despite - // it being a reasonable operation. + // A dereference of a volatile pointer is a side effecting operation, however + // since it is idiomatic code, and the alternatives induce higher maintenance + // costs, it is allowed. int * volatile x; - (void)sizeof(*x); // expected-warning {{expression with side effects has no effect in an unevaluated context}} + (void)sizeof(*x); // Ok } } |

