diff options
author | Marek Polacek <polacek@redhat.com> | 2015-10-21 17:30:20 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2015-10-21 17:30:20 +0000 |
commit | e9122ef60858058cb474b3d3bb51507b7fd1d14c (patch) | |
tree | 4f5c18ed36ede7a92582472a9f43fd6916ea8b86 /gcc/c | |
parent | 68d58afb65a42cb7886552a1532fc11dc06eaed4 (diff) | |
download | gcc-e9122ef60858058cb474b3d3bb51507b7fd1d14c.zip gcc-e9122ef60858058cb474b3d3bb51507b7fd1d14c.tar.gz gcc-e9122ef60858058cb474b3d3bb51507b7fd1d14c.tar.bz2 |
re PR c/68024 (Diagnose variadic functions defined without prototypes)
PR c/68024
* c-decl.c (start_function): Warn about vararg functions without
a prototype.
* gcc.dg/pr68024.c: New test.
From-SVN: r229131
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 34aafc2..b5179a3 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2015-10-21 Marek Polacek <polacek@redhat.com> + + PR c/68024 + * c-decl.c (start_function): Warn about vararg functions without + a prototype. + 2015-10-21 Ilya Enkovich <enkovich.gnu@gmail.com> * c-typeck.c (build_conditional_expr): Use boolean vector diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index ce8406a..4a0e090 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -8328,6 +8328,12 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, && comptypes (TREE_TYPE (TREE_TYPE (decl1)), TREE_TYPE (TREE_TYPE (old_decl)))) { + if (stdarg_p (TREE_TYPE (old_decl))) + { + warning_at (loc, 0, "%q+D defined as variadic function " + "without prototype", decl1); + locate_old_decl (old_decl); + } TREE_TYPE (decl1) = composite_type (TREE_TYPE (old_decl), TREE_TYPE (decl1)); current_function_prototype_locus = DECL_SOURCE_LOCATION (old_decl); |