From: mpolacek Date: Wed, 21 Oct 2015 17:30:20 +0000 (+0000) Subject: PR c/68024 X-Git-Tag: upstream/6.1~3906 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5ce1b137aa0429f2ff0bc638272a3a25c160ac18;p=platform%2Fupstream%2Flinaro-gcc.git PR c/68024 * c-decl.c (start_function): Warn about vararg functions without a prototype. * gcc.dg/pr68024.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229131 138bc75d-0d04-0410-961f-82ee72b054a4 --- 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 + + PR c/68024 + * c-decl.c (start_function): Warn about vararg functions without + a prototype. + 2015-10-21 Ilya Enkovich * 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index db0f896..4f10616 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-21 Marek Polacek + + PR c/68024 + * gcc.dg/pr68024.c: New test. + 2015-10-21 Nathan Sidwell * c-c++-common/goacc/clauses-fail.c: Adjust errors. diff --git a/gcc/testsuite/gcc.dg/pr68024.c b/gcc/testsuite/gcc.dg/pr68024.c new file mode 100644 index 0000000..a750917 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr68024.c @@ -0,0 +1,5 @@ +/* PR c/68024 */ +/* { dg-do compile } */ + +void f (int, ...); +void f (a) int a; {} /* { dg-warning "defined as variadic function without prototype" } */