diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-01-12 23:18:54 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-01-12 23:18:54 +0000 |
commit | 49862b8285b62d7222bd91e57f7ea953751d4c93 (patch) | |
tree | ee84083b229af94ca44f6f6772550b01d50befe2 /clang/test | |
parent | 4b0e352061e10a50928154beccfc043ded9e6b84 (diff) | |
download | bcm5719-llvm-49862b8285b62d7222bd91e57f7ea953751d4c93.tar.gz bcm5719-llvm-49862b8285b62d7222bd91e57f7ea953751d4c93.zip |
Don't emit string-comparison or self-comparison warnings in
unevaluated contexts, because they only matter for code that will
actually be evaluated at runtime.
As part of this, I had to extend PartialDiagnostic to support fix-it
hints.
llvm-svn: 93266
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Sema/exprs.c | 4 | ||||
-rw-r--r-- | clang/test/Sema/self-comparison.c | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c index 9059cac22e5..9acc63fa41a 100644 --- a/clang/test/Sema/exprs.c +++ b/clang/test/Sema/exprs.c @@ -87,6 +87,10 @@ int test12(const char *X) { return X == "foo"; // expected-warning {{comparison against a string literal is unspecified}} } +int test12b(const char *X) { + return sizeof(X == "foo"); // no-warning +} + // rdar://6719156 void test13( void (^P)()) { // expected-error {{blocks support disabled - compile with -fblocks}} diff --git a/clang/test/Sema/self-comparison.c b/clang/test/Sema/self-comparison.c index b2b06c209a6..1baba2755f4 100644 --- a/clang/test/Sema/self-comparison.c +++ b/clang/test/Sema/self-comparison.c @@ -31,3 +31,8 @@ int compare_enum() { enum { A }; return A == A; // no-warning } + +// Don't complain in unevaluated contexts. +int compare_sizeof(int x) { + return sizeof(x == x); // no-warning +} |