re PR c++/64629 (-Wformat-security warns with const char *const vars)
PR c++/64629 * c-format.c (check_format_arg): Call decl_constant_value. From-SVN: r219964
This commit is contained in:
parent
4195393b3c
commit
6875457f34
3 changed files with 22 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2015-01-21 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/64629
|
||||
* c-format.c (check_format_arg): Call decl_constant_value.
|
||||
|
||||
2015-01-19 Martin Liska <mliska@suse.cz>
|
||||
|
||||
* c-common.c (handle_noicf_attribute): New function.
|
||||
|
|
|
@ -1443,6 +1443,13 @@ check_format_arg (void *ctx, tree format_tree,
|
|||
tree array_init;
|
||||
alloc_pool fwt_pool;
|
||||
|
||||
if (TREE_CODE (format_tree) == VAR_DECL)
|
||||
{
|
||||
/* Pull out a constant value if the front end didn't. */
|
||||
format_tree = decl_constant_value (format_tree);
|
||||
STRIP_NOPS (format_tree);
|
||||
}
|
||||
|
||||
if (integer_zerop (format_tree))
|
||||
{
|
||||
/* Skip to first argument to check, so we can see if this format
|
||||
|
|
10
gcc/testsuite/g++.dg/warn/Wformat-1.C
Normal file
10
gcc/testsuite/g++.dg/warn/Wformat-1.C
Normal file
|
@ -0,0 +1,10 @@
|
|||
// PR c++/64629
|
||||
// { dg-options "-Wformat -Wformat-security" }
|
||||
|
||||
extern void bar (int, const char *, ...) __attribute__((format (printf, 2, 3)));
|
||||
void
|
||||
foo (void)
|
||||
{
|
||||
const char *const msg = "abc";
|
||||
bar (1, msg);
|
||||
}
|
Loading…
Add table
Reference in a new issue