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:
parent
46be79e789
commit
04d57dd504
5 changed files with 53 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -917,6 +917,12 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
|
|||
if (TREE_TYPE (value) == 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)
|
||||
return void_type_node;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" } */
|
||||
};
|
||||
|
|
|
@ -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" } */
|
||||
|
|
Loading…
Add table
Reference in a new issue