From 1a6babf1f41c3c8d6a0dab98e02b7caaf9024da6 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 13 Oct 2009 04:53:48 +0000 Subject: make the diagnostic in the 'unused result' warning more precise about the reason, rdar://7186119. llvm-svn: 83940 --- clang/test/Sema/attr-warn_unused_result.c | 6 +++--- clang/test/Sema/unused-expr.c | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'clang/test') diff --git a/clang/test/Sema/attr-warn_unused_result.c b/clang/test/Sema/attr-warn_unused_result.c index b4ef1bbeaf0..08e95f4f61d 100644 --- a/clang/test/Sema/attr-warn_unused_result.c +++ b/clang/test/Sema/attr-warn_unused_result.c @@ -9,9 +9,9 @@ int foo() { if (fn1() < 0 || fn2(2,1) < 0 || fn3(2) < 0) // no warnings return -1; - fn1(); // expected-warning {{expression result unused}} - fn2(92, 21); // expected-warning {{expression result unused}} - fn3(42); // expected-warning {{expression result unused}} + fn1(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}} + fn2(92, 21); // expected-warning {{ignoring return value of function declared with pure attribute}} + fn3(42); // expected-warning {{ignoring return value of function declared with const attribute}} return 0; } diff --git a/clang/test/Sema/unused-expr.c b/clang/test/Sema/unused-expr.c index 8b5d1561262..f8e7c91474a 100644 --- a/clang/test/Sema/unused-expr.c +++ b/clang/test/Sema/unused-expr.c @@ -25,7 +25,7 @@ void bar(volatile int *VP, int *P, int A, __real__ VC; // We know this can't change errno because of -fno-math-errno. - sqrt(A); // expected-warning {{expression result unused}} + sqrt(A); // expected-warning {{ignoring return value of function declared with const attribute}} } extern void t1(); @@ -73,4 +73,8 @@ void t4(int a) { for (;;b == 1) {} // expected-warning{{expression result unused}} } - +// rdar://7186119 +int t5f(void) __attribute__((warn_unused_result)); +void t5() { + t5f(); // expected-warning {{ignoring return value of function declared with warn_unused_result}} +} -- cgit v1.2.3