PR c/7353 redux

PR c/7353 redux
cp:
	* decl2.c (grokfield): Reject TYPE_DECLs with initializers.
testsuite:
	* g++.dg/ext/typedef-init.C, gcc.dg/typedef-init.C:
	Add some more cases.

From-SVN: r58737
This commit is contained in:
Zack Weinberg 2002-11-02 02:17:41 +00:00 committed by Zack Weinberg
parent 46be79e789
commit 04d57dd504
5 changed files with 53 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2002-11-01 Zack Weinberg <zack@codesourcery.com>
PR c/7353 redux
* decl2.c (grokfield): Reject TYPE_DECLs with initializers.
2002-10-30 Jason Merrill <jason@redhat.com>
PR c++/8186
@ -21,7 +26,7 @@
PR c++/8149
* decl.c (make_typename_type): Issue errors about invalid results.
2002-10-30 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Core issue 287, PR c++/7639
@ -77,7 +82,7 @@
* pt.c (build_template_decl): Don't set it.
(tsubst_decl): Likewise.
* typeck.c (expand_ptrmemfunc_cst): Don't use it.
* class.c (build_vtbl_initializer): Don't use build_vtable_entry.
(build_vtable_entry): Remove.
* cp-tree.h (BINFO_VIRTUALS): Expand documentation.

View File

@ -915,7 +915,13 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
/* friend or constructor went bad. */
return value;
if (TREE_TYPE (value) == error_mark_node)
return error_mark_node;
return error_mark_node;
if (TREE_CODE (value) == TYPE_DECL && init)
{
error ("typedef `%D' is initialized (use __typeof__ instead)", value);
init = NULL_TREE;
}
/* Pass friendly classes back. */
if (TREE_CODE (value) == VOID_TYPE)

View File

@ -1,3 +1,8 @@
2002-11-01 Zack Weinberg <zack@codesourcery.com>
* g++.dg/ext/typedef-init.C, gcc.dg/typedef-init.C:
Add some more cases.
2002-11-01 Mark Mitchell <mark@codesourcery.com>
PR c++/8391

View File

@ -5,10 +5,29 @@
it's been broken since GCC 3.0 (caused ICE) and we have now removed
the extension. See PR c/7353.
C++ issues a warning in addition to the error, since this construct
appears to be a case of implicit int (forbidden in std. C++) until
we get to the equals sign. */
For cases A and C, C++ issues a warning in addition to the error,
since this construct appears to be a case of implicit int
(forbidden in std. C++) until we get to the equals sign. */
typedef A = 0; /* { dg-error "initialized" "typedef A = B" } */
/* { dg-warning "no type" "also warns" { target *-*-* } 12 } */
A a; /* { dg-bogus "" "no error cascade" } */
/* Case A: just the bare name = initializer. */
typedef A = 0; /* { dg-error "initialized" "A" } */
/* { dg-warning "no type" "A warns" { target *-*-* } 14 } */
A a; /* { dg-bogus "" "A error cascade" } */
/* Case B: with a type also. */
typedef int B = 0; /* { dg-error "initialized" "B" } */
B b; /* { dg-bogus "" "B error cascade" } */
/* C and D are the same as A and B, but wrapped in a structure;
field declarations go by a different code path in C++ (ick). */
struct S {
typedef C = 0; /* { dg-error "initialized" "C" } */
/* { dg-warning "no type" "C warns" { target *-*-* } 27 } */
C c; /* { dg-bogus "" "C error cascade" } */
typedef int D = 0; /* { dg-error "initialized" "D" } */
D d; /* { dg-bogus "" "D error cascade" } */
};

View File

@ -5,5 +5,12 @@
it's been broken since GCC 3.0 (caused ICE) and we have now removed
the extension. See PR c/7353. */
typedef A = 0; /* { dg-error "initialized" "typedef A = B" } */
A a; /* { dg-bogus "" "no error cascade" } */
/* Case A: just the bare name = initializer. */
typedef A = 0; /* { dg-error "initialized" "A" } */
A a; /* { dg-bogus "" "A error cascade" } */
/* Case B: with a type also. */
typedef int B = 0; /* { dg-error "initialized" "B" } */
B b; /* { dg-bogus "" "B error cascade" } */