-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #655 from ehaas/callable-tok
Improve unused result diagnostics
- Loading branch information
Showing
4 changed files
with
84 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,34 @@ | ||
typedef int (*fnptr)(int, int); | ||
|
||
|
||
int foo() __attribute__((warn_unused_result)) { | ||
return 0; | ||
} | ||
|
||
void bar() { | ||
fnptr make_fn(int a, int b) { | ||
return 0; | ||
} | ||
|
||
void bar(fnptr ptr) { | ||
foo(); | ||
(foo)(); | ||
(foo - 16)(); | ||
(foo + 16)(); | ||
(*****foo)(); | ||
make_fn(1, 2)(2, 2); | ||
} | ||
|
||
struct S { | ||
int __attribute__((warn_unused_result))(*close)(void); | ||
}; | ||
|
||
void baz(struct S *s){ | ||
(bar(0), s->close)(); | ||
} | ||
|
||
|
||
#define EXPECTED_ERRORS "warn unused result.c:13:4: warning: ignoring return value of 'foo', declared with 'warn_unused_result' attribute [-Wunused-result]" \ | ||
"warn unused result.c:14:4: warning: ignoring return value of 'foo', declared with 'warn_unused_result' attribute [-Wunused-result]" \ | ||
"warn unused result.c:17:4: warning: ignoring return value of 'foo', declared with 'warn_unused_result' attribute [-Wunused-result]" \ | ||
"warn unused result.c:26:5: warning: ignoring return value of 'close', declared with 'warn_unused_result' attribute [-Wunused-result]" \ | ||
|
||
#define EXPECTED_ERRORS "warn unused result.c:6:4: warning: ignoring return value of 'foo', declared with 'warn_unused_result' attribute [-Wunused-result]" |