Commit a16f2357 by Geoffrey Keating Committed by Geoffrey Keating

Index: cp/ChangeLog

2002-11-26  Geoffrey Keating  <geoffk@apple.com>

	* 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  <geoffk@apple.com>

	* g++.dg/init/brace2.C: New test.
	* g++.old-deja/g++.mike/p9129.C: Correct.

From-SVN: r59553
parent 0ef08cc4
2002-11-26 Geoffrey Keating <geoffk@apple.com>
* decl.c (check_initializer): Don't error on initialisation of
a scalar with a brace-enclosed expression.
2002-11-26 Nathan Sidwell <nathan@codesourcery.com> 2002-11-26 Nathan Sidwell <nathan@codesourcery.com>
* cp-tree.h (DECL_LANG_FLAG_4): Document more uses. * cp-tree.h (DECL_LANG_FLAG_4): Document more uses.
......
...@@ -8017,7 +8017,19 @@ check_initializer (tree decl, tree init, int flags) ...@@ -8017,7 +8017,19 @@ check_initializer (tree decl, tree init, int flags)
else if (init) else if (init)
{ {
if (TREE_CODE (init) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (init)) if (TREE_CODE (init) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (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); init = reshape_init (type, &init);
}
/* If DECL has an array type without a specific bound, deduce the /* If DECL has an array type without a specific bound, deduce the
array size from the initializer. */ array size from the initializer. */
......
2002-11-26 Geoffrey Keating <geoffk@apple.com>
* g++.dg/init/brace2.C: New test.
* g++.old-deja/g++.mike/p9129.C: Correct.
2002-11-26 Mark Mitchell <mark@codesourcery.com> 2002-11-26 Mark Mitchell <mark@codesourcery.com>
* g++.dg/abi/empty10.C: Don't run on non-x86 targets. * g++.dg/abi/empty10.C: Don't run on non-x86 targets.
......
// { 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" }
...@@ -7,6 +7,6 @@ public: ...@@ -7,6 +7,6 @@ public:
int DoSomething(); int DoSomething();
}; };
int (Foo::*pA)() = { &Foo::DoSomething }; // ERROR - int (Foo::*pA)() = { &Foo::DoSomething };
int (Foo::*X[1])(int) = { { &Foo::DoSomething } }; // ERROR - int (Foo::*X[1])(int) = { { &Foo::DoSomething } }; // ERROR -
int (Foo::*Y[])(int) = { { &Foo::DoSomething, &Foo::DoSomething, 0 } }; // ERROR - int (Foo::*Y[])(int) = { { &Foo::DoSomething, &Foo::DoSomething, 0 } }; // ERROR -
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment