This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: deprecate default args on non-functions
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Mark Mitchell <mitchell at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 25 Jul 2003 18:28:44 +0100
- Subject: [C++ PATCH]: deprecate default args on non-functions
- Organization: Codesourcery LLC
Hi,
this patch deprecates default arguments except on parameter declarations
of functions. I also update the docs to show that implicit typename is gone.
ok?
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2003-07-25 Nathan Sidwell <nathan@codesourcery.com>
* doc/extend.texi (Deprecated Features): Implicit typename is
gone. Default args on types is going.
2003-07-25 Nathan Sidwell <nathan@codesourcery.com>
* parser.c (cp_parser_type_parameter): Reformat.
(cp_parser_parameter_declaration): Deprecate default args where
not allowed.
Index: doc/extend.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/extend.texi,v
retrieving revision 1.151
diff -c -3 -p -r1.151 extend.texi
*** doc/extend.texi 25 Jul 2003 10:52:31 -0000 1.151
--- doc/extend.texi 25 Jul 2003 17:12:31 -0000
*************** Predefined Macros,cpp.info,The C Preproc
*** 7290,7296 ****
method denoted by a @samp{->*} or @samp{.*} expression.
* C++ Attributes:: Variable, function, and type attributes for C++ only.
* Java Exceptions:: Tweaking exception handling to work with Java.
! * Deprecated Features:: Things might disappear from g++.
* Backwards Compatibility:: Compatibilities with earlier definitions of C++.
@end menu
--- 7290,7296 ----
method denoted by a @samp{->*} or @samp{.*} expression.
* C++ Attributes:: Variable, function, and type attributes for C++ only.
* Java Exceptions:: Tweaking exception handling to work with Java.
! * Deprecated Features:: Things will disappear from g++.
* Backwards Compatibility:: Compatibilities with earlier definitions of C++.
@end menu
*************** and is now removed from g++.
*** 7963,7972 ****
Floating and complex non-type template parameters have been deprecated,
and are now removed from g++.
! The implicit typename extension has been deprecated and will be removed
! from g++ at some point. In some cases g++ determines that a dependent
! type such as @code{TPL<T>::X} is a type without needing a
! @code{typename} keyword, contrary to the standard.
@node Backwards Compatibility
@section Backwards Compatibility
--- 7963,7974 ----
Floating and complex non-type template parameters have been deprecated,
and are now removed from g++.
! The implicit typename extension has been deprecated and is now
! removed from g++.
!
! The use of default arguments in function pointers, function typedefs and
! and other places where they are not permitted by the standard is
! deprecated and will be removed from a future version of g++.
@node Backwards Compatibility
@section Backwards Compatibility
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.88
diff -c -3 -p -r1.88 parser.c
*** cp/parser.c 23 Jul 2003 13:02:30 -0000 1.88
--- cp/parser.c 25 Jul 2003 17:17:32 -0000
*************** cp_parser_type_parameter (cp_parser* par
*** 7305,7312 ****
/* Create the combined representation of the parameter and the
default argument. */
! parameter = build_tree_list (default_argument,
! parameter);
}
break;
--- 7305,7311 ----
/* Create the combined representation of the parameter and the
default argument. */
! parameter = build_tree_list (default_argument, parameter);
}
break;
*************** cp_parser_type_parameter (cp_parser* par
*** 7365,7372 ****
/* Create the combined representation of the parameter and the
default argument. */
! parameter = build_tree_list (default_argument,
! parameter);
}
break;
--- 7364,7370 ----
/* Create the combined representation of the parameter and the
default argument. */
! parameter = build_tree_list (default_argument, parameter);
}
break;
*************** cp_parser_parameter_declaration (cp_pars
*** 10498,10506 ****
}
if (!parser->default_arg_ok_p)
{
! pedwarn ("default arguments are only permitted on functions");
! if (flag_pedantic_errors)
! default_argument = NULL_TREE;
}
}
else
--- 10496,10508 ----
}
if (!parser->default_arg_ok_p)
{
! if (!flag_pedantic_errors)
! warning ("deprecated use of default argument for parameter of non-function");
! else
! {
! error ("default arguments are only permitted for function parameters");
! default_argument = NULL_TREE;
! }
}
}
else
// { dg-do compile }
// { dg-options "-fpermissive" }
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 25 Jul 2003 <nathan@codesourcery.com>
// default arguments can only be for a function
// declaration. Deprecated in 3.4
typedef int (*fp_t) (int = 1); // { dg-warning "deprecated" "" }
int (*fp) (int = 1); // { dg-warning "deprecated" "" }
int Foo (int (*)(int = 1)); // { dg-warning "deprecated" "" }