]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c/7353 redux
authorZack Weinberg <zack@codesourcery.com>
Sat, 2 Nov 2002 10:28:50 +0000 (10:28 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Sat, 2 Nov 2002 10:28:50 +0000 (10:28 +0000)
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: r58747

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/typedef-init.C
gcc/testsuite/gcc.dg/typedef-init.c

index b6f2ff5be7a03215dfb27df13dd8851889fd0a0c..6f7126138b330906a9d9c38ec5dbc54dbf3696d2 100644 (file)
@@ -1,3 +1,8 @@
+2002-11-02  Zack Weinberg  <zack@codesourcery.com>
+
+       PR c/7353 redux
+       * decl2.c (grokfield): Reject TYPE_DECLs with initializers.
+
 2002-11-01  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        PR C++/2521
@@ -10,7 +15,7 @@
 
        PR c++/8149
        * decl.c (make_typename_type): Issue errors about invalid results.
-       
+
 2002-10-29  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/8287
index 871fefc5130285eb0556f1cec30edac59e28b336..730bbfb55f000ab83ea91440c938ff9fb97ed3b5 100644 (file)
@@ -1519,7 +1519,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)
index f4e91604fb7305aa30bf11f643a17d424bbc1c0f..6ff26316a08971f876dd8f456b73fbe1a91774bd 100644 (file)
@@ -1,3 +1,8 @@
+2002-11-02  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
index 5602783b4990e3f671f6def24f574eeffffb97e8..1b2a05db63c810826bbd5f75000b2106309cb9ac 100644 (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" } */
+};
index 9cb4830b74bd74f8b73f80b209f808422cc130f0..52928da9a6916265a0bd10102a3ded45d60023f6 100644 (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" } */