gkeating 02/11/26 18:04:03 Modified: live/gcc3/gcc/cp decl.c live/gcc3/gcc/testsuite/g++.old-deja/g++.mike p9129.C Added: live/gcc3/gcc/testsuite/g++.dg/init brace2.C Log: Merge from FSF GCC: Index: cp/ChangeLog 2002-11-26 Geoffrey Keating <[EMAIL PROTECTED]> * decl.c (check_initializer): Don't error on initialisation of a scalar with a brace-enclosed expression. Index: testsuite/ChangeLog 2002-11-26 Geoffrey Keating <[EMAIL PROTECTED]> * g++.dg/init/brace2.C: New test. * g++.old-deja/g++.mike/p9129.C: Correct. Revision Changes Path 1.122 +13 -1 src/live/gcc3/gcc/cp/decl.c Index: decl.c =================================================================== RCS file: /cvs/Darwin/src/live/gcc3/gcc/cp/decl.c,v retrieving revision 1.121 retrieving revision 1.122 diff -u -r1.121 -r1.122 --- decl.c 2002/11/01 21:56:01 1.121 +++ decl.c 2002/11/27 02:04:01 1.122 @@ -8274,7 +8274,19 @@ else if (init) { if (TREE_CODE (init) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (init)) - init = reshape_init (type, &init); + { + /* [dcl.init] paragraph 13, + If T is a scalar type, then a declaration of the form + T x = { a }; + is equivalent to + T x = a; + + reshape_init will complain about the extra braces, + and doesn't do anything useful in the case where TYPE is + scalar, so just don't call it. */ + if (CP_AGGREGATE_TYPE_P (type)) + init = reshape_init (type, &init); + } /* If DECL has an array type without a specific bound, deduce the array size from the initializer. */ 1.1 src/live/gcc3/gcc/testsuite/g++.dg/init/brace2.C Index: brace2.C =================================================================== // { dg-do compile } // [dcl.init] paragraph 13. int x = { 2 }; const char * y = { "hello" }; int a = 2; int b = { 2,3 }; // { dg-error "requires one element" } int c = { { 2 } } ; // { dg-error "braces around scalar initializer" } 1.4 +1 -1 src/live/gcc3/gcc/testsuite/g++.old-deja/g++.mike/p9129.C Index: p9129.C =================================================================== RCS file: /cvs/Darwin/src/live/gcc3/gcc/testsuite/g++.old-deja/g++.mike/p9129.C,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- p9129.C 2002/10/24 23:49:33 1.3 +++ p9129.C 2002/11/27 02:04:03 1.4 @@ -7,6 +7,6 @@ int DoSomething(); }; -int (Foo::*pA)() = { &Foo::DoSomething }; // ERROR - +int (Foo::*pA)() = { &Foo::DoSomething }; int (Foo::*X[1])(int) = { { &Foo::DoSomething } }; // ERROR - int (Foo::*Y[])(int) = { { &Foo::DoSomething, &Foo::DoSomething, 0 } }; // ERROR -