This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Deprecate new initializer lists
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH] Deprecate new initializer lists
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Fri, 09 Feb 2001 09:33:55 +0000
- Organization: Codesourcery LLC
Hi,
this patch deprecates the new initializer list extension.
new T = {....};
This doesn't remove the extension, merely marks it for later removal.
built & tested on i686-pc-linux-gnu, ok?
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-02-09 Nathan Sidwell <nathan@codesourcery.com>
* extend.texi (Deprecated): Deprecate new initializer lists.
2001-02-09 Nathan Sidwell <nathan@codesourcery.com>
* errfn.c (cp_deprecated): Tweak diagnostic text.
* parse.y (new_initializer): Deprecate initializer lists
extension.
2001-02-09 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.robertl/eb63.C: Remove new initializer list
case.
Index: cp/errfn.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/errfn.c,v
retrieving revision 1.29
diff -c -3 -p -r1.29 errfn.c
*** errfn.c 2000/09/21 03:43:13 1.29
--- errfn.c 2001/02/09 09:25:54
*************** cp_deprecated (msg)
*** 265,272 ****
extern int warn_deprecated;
if (!warn_deprecated)
return;
! cp_warning ("%s is deprecated.", msg);
! cp_warning ("Please see the documentation for details.");
}
void
--- 265,271 ----
extern int warn_deprecated;
if (!warn_deprecated)
return;
! cp_warning ("%s is deprecated, please see the documentation for details", msg);
}
void
Index: cp/parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/parse.y,v
retrieving revision 1.212
diff -c -3 -p -r1.212 parse.y
*** parse.y 2001/01/29 18:57:22 1.212
--- parse.y 2001/02/09 09:25:59
*************** new_initializer:
*** 1290,1300 ****
}
/* GNU extension so people can use initializer lists. Note that
this alters the meaning of `new int = 1', which was previously
! syntactically valid but semantically invalid. */
| '=' init
{
if (pedantic)
pedwarn ("ISO C++ forbids initialization of new expression with `='");
if (TREE_CODE ($2) != TREE_LIST
&& TREE_CODE ($2) != CONSTRUCTOR)
$$ = build_tree_list (NULL_TREE, $2);
--- 1290,1303 ----
}
/* GNU extension so people can use initializer lists. Note that
this alters the meaning of `new int = 1', which was previously
! syntactically valid but semantically invalid.
! This feature is now deprecated and will be removed in a future
! release. */
| '=' init
{
if (pedantic)
pedwarn ("ISO C++ forbids initialization of new expression with `='");
+ cp_deprecated ("new initializer lists extension");
if (TREE_CODE ($2) != TREE_LIST
&& TREE_CODE ($2) != CONSTRUCTOR)
$$ = build_tree_list (NULL_TREE, $2);
Index: extend.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/extend.texi,v
retrieving revision 1.92
diff -c -3 -p -r1.92 extend.texi
*** extend.texi 2001/02/05 23:57:14 1.92
--- extend.texi 2001/02/09 09:26:04
*************** it is required for backwards compatibili
*** 4390,4395 ****
--- 4390,4398 ----
The named return value extension has been deprecated, and will be
removed from g++ at some point.
+ The use of initializer lists with new expressions has been deprecated,
+ and will be removed from g++ at some point.
+
@node Backwards Compatibility
@section Backwards Compatibility
@cindex Backwards Compatibility
Index: testsuite/g++.old-deja/g++.robertl/eb63.C
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/g++.old-deja/g++.robertl/eb63.C,v
retrieving revision 1.4
diff -c -3 -p -r1.4 eb63.C
*** eb63.C 2000/05/28 05:38:02 1.4
--- eb63.C 2001/02/09 09:26:04
*************** public:
*** 11,16 ****
main() {
A* a;
! a = new A[2] = { A(1,false), A(1,false) } ;
a = new A[2](1,false);
}
--- 11,16 ----
main() {
A* a;
!
a = new A[2](1,false);
}