re PR c++/28741 (ICE with static member in invalid template class)
authorLee Millward <lee.millward@codesourcery.com>
Mon, 21 Aug 2006 17:41:18 +0000 (17:41 +0000)
committerLee Millward <lmillward@gcc.gnu.org>
Mon, 21 Aug 2006 17:41:18 +0000 (17:41 +0000)
        PR c++/28741
        * tree.c (decl_anon_ns_mem_p): Robustify.
        * decl2.c (determine_visibility): Likewise.

        * g++.dg/template/void7.C: New test.

From-SVN: r116303

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/void7.C [new file with mode: 0644]

index 10d0538f80b62f67bd0417c02554e142f524ae8b..758f877187fea5995c62691d3ea4fb9a6430fe11 100644 (file)
@@ -7,6 +7,10 @@
         PR c++/28505
         * decl.c (grokdeclarator): Return early after
         issuing diagnostic about an incomplete type.
+
+       PR c++/28741
+        * tree.c (decl_anon_ns_mem_p): Robustify.
+        * decl2.c (determine_visibility): Likewise.
        
 2006-08-20  Mark Mitchell  <mark@codesourcery.com>
 
index 8b39b81901a04383d41b1822aa00b8d956b14a1d..0de2756620e8cd10dc0a7d8acea3cc3110fba295 100644 (file)
@@ -1753,20 +1753,24 @@ determine_visibility (tree decl)
                    ? TYPE_TEMPLATE_INFO (TREE_TYPE (decl))
                    : DECL_TEMPLATE_INFO (decl));
       tree args = TI_ARGS (tinfo);
-      int depth = TMPL_ARGS_DEPTH (args);
-      tree pattern = DECL_TEMPLATE_RESULT (TI_TEMPLATE (tinfo));
-
-      if (!DECL_VISIBILITY_SPECIFIED (decl))
+      
+      if (args != error_mark_node)
        {
-         DECL_VISIBILITY (decl) = DECL_VISIBILITY (pattern);
-         DECL_VISIBILITY_SPECIFIED (decl)
-           = DECL_VISIBILITY_SPECIFIED (pattern);
-       }
+         int depth = TMPL_ARGS_DEPTH (args);
+         tree pattern = DECL_TEMPLATE_RESULT (TI_TEMPLATE (tinfo));
+
+         if (!DECL_VISIBILITY_SPECIFIED (decl))
+           {
+             DECL_VISIBILITY (decl) = DECL_VISIBILITY (pattern);
+             DECL_VISIBILITY_SPECIFIED (decl)
+               = DECL_VISIBILITY_SPECIFIED (pattern);
+           }
 
-      /* FIXME should TMPL_ARGS_DEPTH really return 1 for null input? */
-      if (args && depth > template_class_depth (class_type))
-       /* Limit visibility based on its template arguments.  */
-       constrain_visibility_for_template (decl, args);
+         /* FIXME should TMPL_ARGS_DEPTH really return 1 for null input? */
+         if (args && depth > template_class_depth (class_type))
+           /* Limit visibility based on its template arguments.  */
+           constrain_visibility_for_template (decl, args);
+       }
     }
 
   if (class_type)
index 90839b73ab3e5ab4a8732f0c9c94d17aad4b0d01..bb579a6f739984977bec883b78e269e39ec02485 100644 (file)
@@ -1393,7 +1393,7 @@ decl_anon_ns_mem_p (tree decl)
 {
   while (1)
     {
-      if (decl == NULL_TREE)
+      if (decl == NULL_TREE || decl == error_mark_node)
        return false;
       if (TREE_CODE (decl) == NAMESPACE_DECL
          && DECL_NAME (decl) == NULL_TREE)
index a277501ab34a1d5d29308ca98cb879c76925d9a2..c40d5007caeb444ae9ee53a8f7e291c2785a8ee2 100644 (file)
@@ -6,6 +6,9 @@
         PR c++/28505
         * g++.dg/parse/ctor7.C: New test.
         * g++.dg/parse/ctor8.C: Likewise.
+
+       PR c++/28741
+        * g++.dg/template/void7.C: New test. 
        
 2006-08-21  Olivier Hainque  <hainque@adacore.com>
 
diff --git a/gcc/testsuite/g++.dg/template/void7.C b/gcc/testsuite/g++.dg/template/void7.C
new file mode 100644 (file)
index 0000000..2c464b3
--- /dev/null
@@ -0,0 +1,8 @@
+//PR c++/28741
+
+template<void> struct A         // { dg-error "not a valid type" }
+{
+  static int i;
+};
+
+A<0> a;