aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2019-11-08 01:21:40 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2019-11-08 01:21:40 +0000
commit017c6491077bee998eed9ed6520026285c906d37 (patch)
tree17e627d2d781e8f6c48233b95f8bec50f1734fe2 /gcc/c-family
parent3d6e7aa95cf3b354dded4cb1a8c546cbe217beb9 (diff)
downloadgcc-017c6491077bee998eed9ed6520026285c906d37.zip
gcc-017c6491077bee998eed9ed6520026285c906d37.tar.gz
gcc-017c6491077bee998eed9ed6520026285c906d37.tar.bz2
Handle removal of old-style function definitions in C2x.
C2x removes support for old-style function definitions with identifier lists, changing () in function definitions to be equivalent to (void) (while () in declarations that are not definitions still gives an unprototyped type). This patch updates GCC accordingly. The new semantics for () are implemented for C2x mode (meaning () in function definitions isn't diagnosed by -Wold-style-definition in that mode). -Wold-style-definition is enabled by default, and turned into a pedwarn, for C2x. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc: * doc/invoke.texi (-Wold-style-definition): Document () not being considered an old-style definition for C2x. gcc/c: * c-decl.c (grokparms): Convert () in a function definition to (void) for C2x. (store_parm_decls_oldstyle): Pedwarn for C2x. (store_parm_decls): Update comment about () not generating a prototype. gcc/c-family: * c.opt (Wold-style-definition): Initialize to -1. * c-opts.c (c_common_post_options): Set warn_old_style_definition to flag_isoc2x if not set explicitly. gcc/testsuite: * gcc.dg/c11-old-style-definition-1.c, gcc.dg/c11-old-style-definition-2.c, gcc.dg/c2x-old-style-definition-1.c, gcc.dg/c2x-old-style-definition-2.c, gcc.dg/c2x-old-style-definition-3.c, gcc.dg/c2x-old-style-definition-4.c, gcc.dg/c2x-old-style-definition-5.c, gcc.dg/c2x-old-style-definition-6.c: New tests. From-SVN: r277945
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog6
-rw-r--r--gcc/c-family/c-opts.c4
-rw-r--r--gcc/c-family/c.opt2
3 files changed, 11 insertions, 1 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 39e7d5a..d3e328f 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-08 Joseph Myers <joseph@codesourcery.com>
+
+ * c.opt (Wold-style-definition): Initialize to -1.
+ * c-opts.c (c_common_post_options): Set warn_old_style_definition
+ to flag_isoc2x if not set explicitly.
+
2019-11-07 Joseph Myers <joseph@codesourcery.com>
* c-attribs.c (parse_tm_stmt_attr): Handle scoped attributes.
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index b84f05c..75b6959 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -904,6 +904,10 @@ c_common_post_options (const char **pfilename)
if (warn_implicit_int == -1)
warn_implicit_int = flag_isoc99;
+ /* -Wold-style-definition is enabled by default for C2X. */
+ if (warn_old_style_definition == -1)
+ warn_old_style_definition = flag_isoc2x;
+
/* -Wshift-overflow is enabled by default in C99 and C++11 modes. */
if (warn_shift_overflow == -1)
warn_shift_overflow = cxx_dialect >= cxx11 || flag_isoc99;
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index bb6eeaf..914a2f0 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -960,7 +960,7 @@ C ObjC Var(warn_old_style_declaration) Warning EnabledBy(Wextra)
Warn for obsolescent usage in a declaration.
Wold-style-definition
-C ObjC Var(warn_old_style_definition) Warning
+C ObjC Var(warn_old_style_definition) Init(-1) Warning
Warn if an old-style parameter definition is used.
Wopenmp-simd