public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1144] analyzer: associate -Wanalyzer-va-list-exhausted with CWE-685 Date: Thu, 16 Jun 2022 21:34:48 +0000 (GMT) [thread overview] Message-ID: <20220616213448.A3AF63856261@sourceware.org> (raw) https://gcc.gnu.org/g:f443024bca7c1ac988eb7c05e639b017347ee714 commit r13-1144-gf443024bca7c1ac988eb7c05e639b017347ee714 Author: David Malcolm <dmalcolm@redhat.com> Date: Thu Jun 16 17:33:40 2022 -0400 analyzer: associate -Wanalyzer-va-list-exhausted with CWE-685 gcc/analyzer/ChangeLog: * varargs.cc: Include "diagnostic-metadata.h". (va_list_exhausted::emit): Associate the warning with CWE-685 ("Function Call With Incorrect Number of Arguments"). gcc/testsuite/ChangeLog: * gcc.dg/analyzer/stdarg-1.c (__analyzer_called_by_test_not_enough_args): Verify that -Wanalyzer-va-list-exhausted is associated with CWE-685. Signed-off-by: David Malcolm <dmalcolm@redhat.com> Diff: --- gcc/analyzer/varargs.cc | 10 +++++++--- gcc/testsuite/gcc.dg/analyzer/stdarg-1.c | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gcc/analyzer/varargs.cc b/gcc/analyzer/varargs.cc index 846a0b1e3ff..3baba7988c1 100644 --- a/gcc/analyzer/varargs.cc +++ b/gcc/analyzer/varargs.cc @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "sbitmap.h" #include "analyzer/diagnostic-manager.h" #include "analyzer/exploded-graph.h" +#include "diagnostic-metadata.h" #if ENABLE_ANALYZER @@ -903,9 +904,12 @@ public: bool emit (rich_location *rich_loc) final override { auto_diagnostic_group d; - bool warned = warning_at (rich_loc, get_controlling_option (), - "%qE has no more arguments (%i consumed)", - m_va_list_tree, get_num_consumed ()); + diagnostic_metadata m; + /* CWE-685: Function Call With Incorrect Number of Arguments. */ + m.add_cwe (685); + bool warned = warning_meta (rich_loc, m, get_controlling_option (), + "%qE has no more arguments (%i consumed)", + m_va_list_tree, get_num_consumed ()); return warned; } diff --git a/gcc/testsuite/gcc.dg/analyzer/stdarg-1.c b/gcc/testsuite/gcc.dg/analyzer/stdarg-1.c index 295f0efb74d..41935f74cc3 100644 --- a/gcc/testsuite/gcc.dg/analyzer/stdarg-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/stdarg-1.c @@ -76,7 +76,7 @@ __analyzer_called_by_test_not_enough_args (int placeholder, ...) s = __builtin_va_arg (ap, char *); __analyzer_eval (s[0] == 'f'); /* { dg-warning "TRUE" } */ - i = __builtin_va_arg (ap, int); /* { dg-warning "'ap' has no more arguments \\(1 consumed\\)" } */ + i = __builtin_va_arg (ap, int); /* { dg-warning "'ap' has no more arguments \\(1 consumed\\) \\\[CWE-685\\\]" } */ __builtin_va_end (ap); }
reply other threads:[~2022-06-16 21:34 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220616213448.A3AF63856261@sourceware.org \ --to=dmalcolm@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).