]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/20789 (ICE with incomplete type in template)
authorNathan Sidwell <nathan@codesourcery.com>
Mon, 13 Jun 2005 17:20:28 +0000 (17:20 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 13 Jun 2005 17:20:28 +0000 (17:20 +0000)
cp:
PR c++/20789
* decl.c (cp_finish_decl): Clear runtime runtime initialization if
in-class decl's initializer is bad.
testsuite:
PR c++/20789
* g++.dg/init/member1.C: New.
* g++.dg/other/warning1.C: Adjust.

From-SVN: r100883

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/member1.C
gcc/testsuite/g++.dg/other/warning1.C

index 50b59ed8ea32843d02899f9f3aeade2ab1263a16..46941cab29e04823c5db92d041373434a463a694 100644 (file)
@@ -1,3 +1,9 @@
+2005-06-13  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/20789
+       * decl.c (cp_finish_decl): Clear runtime runtime initialization if
+       in-class decl's initializer is bad.
+
 2005-06-10  Aldy Hernandez  <aldyh@redhat.com>
 
        PR c++/10611
index 699fe0225b989f3267114aecb9e098ef45c73456..12622cedfb7ff0a3eb079a752bc8ff71c0f42d8d 100644 (file)
@@ -4919,6 +4919,16 @@ cp_finish_decl (tree decl, tree init, tree asmspec_tree, int flags)
                     "initialized", decl);
              init = NULL_TREE;
            }
+         if (DECL_EXTERNAL (decl) && init)
+           {
+             /* The static data member cannot be initialized by a
+                non-constant when being declared.  */
+             error ("`%D' cannot be initialized by a non-constant expression"
+                    " when being declared", decl);
+             DECL_INITIALIZED_IN_CLASS_P (decl) = 0;
+             init = NULL_TREE;
+           }
+         
          /* Handle:
             
             [dcl.init]
index 95284782d31ce1070752693c1747efb781b757c4..5792daea7c1d2f96dcc69f609d9e2ea0a760ab2e 100644 (file)
@@ -1,3 +1,9 @@
+2005-06-13  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/20789
+       * g++.dg/init/member1.C: New.
+       * g++.dg/other/warning1.C: Adjust.
+
 2005-06-08  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/21903
index 1c89d5a1d43dfb52b5b11529a5b0d2202b9f9792..e94684fa8c0e92c0bfcba5ebf655463997661b33 100644 (file)
@@ -12,7 +12,7 @@ template<typename T> struct C
 {
   static const int i = A<T>::i;  // { dg-error "incomplete" }
   static const int j = i;      // { dg-error "initialized by a non-const" }
-  B<j> b;  // { dg-error "not a valid template arg" }
+  B<j> b;  // { dg-error "cannot be used as template arg" }
 };
 
 C<int> c;
index 109fc46aa22b2c2c18e0f8149b7e0ebb03d9feee..6662c25e6e17554e1e8db459ce974fae69e462fb 100644 (file)
@@ -7,8 +7,8 @@ extern "C" int printf(const char *, ...);
 
 struct S
 {
-  static const float inf = 1.0f / 0.0f; // { dg-warning "1.0|initialization" }
-  static const float nan = 0.0f / 0.0f; // { dg-warning "0.0|initialization" }
+  static const float inf = 1.0f / 0.0f; // { dg-warning "1.0|initializ" }
+  static const float nan = 0.0f / 0.0f; // { dg-warning "0.0|initializ" }
 };
 
 int main()