re PR c++/13975 (ICE on misplaced visibility specifier.)
authorMark Mitchell <mark@codesourcery.com>
Tue, 3 Feb 2004 16:53:27 +0000 (16:53 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 3 Feb 2004 16:53:27 +0000 (16:53 +0000)
PR c++/13975
* tree.h (enum tree_index): Add TI_PUBLIC, TI_PROTECTED, and
TI_PRIVATE.
(access_public_node): Redefine.
(access_protected_node): Likewise.
(access_private_node): Likewise.
* tree.c (build_common_tree_nodes): Create access_public_node,
access_protected_node, and access_private_node.

PR c++/13978
* pt.c (build_non_dependent_expr): Do not build
NON_DEPENDENT_EXPRs for FUNCTION_DECLs or TEMPLATE_DECLs.

PR c++/13968
* semantics.c (finish_id_expression): Do not return an
IDENTIFIER_NODE when lookup finds a VAR_DECL.

PR c++/13975
* parser.c (cp_parser_simple_declaration): When skipping to the
end of the statement swallow the terminating semicolon.

PR c++/13978
* g++.dg/template/koenig4.C: New test.

PR c++/13968
* g++.dg/template/crash17.C: New test.

PR c++/13975
* g++.dg/parse/error13.C: New test.
* g++.old-deja/g++.robertl/eb125.C: Tweak error messages.

From-SVN: r77176

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/crash17.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/koenig4.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.robertl/eb125.C
gcc/tree.c
gcc/tree.h

index 212e60fe4866ea1766460ef9a4063546f40e310b..eedaab5d58d62e3164785b13f6d454a0cba9e005 100644 (file)
@@ -1,3 +1,14 @@
+2004-02-03  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/13975
+       * tree.h (enum tree_index): Add TI_PUBLIC, TI_PROTECTED, and
+       TI_PRIVATE.
+       (access_public_node): Redefine.
+       (access_protected_node): Likewise.
+       (access_private_node): Likewise.
+       * tree.c (build_common_tree_nodes): Create access_public_node,
+       access_protected_node, and access_private_node.
+
 2004-02-03  Steve Ellcey  <sje@cup.hp.com>
 
        * config/ia64/ia64.h (MASK_INLINE_INT_DIV_LAT): Change value.
index 9c3d5732edb53367aa4c92372137355073f4768c..221fbe627a96fdfffebc2fb431907639c0663230 100644 (file)
@@ -1,3 +1,17 @@
+2004-02-03  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/13978
+       * pt.c (build_non_dependent_expr): Do not build
+       NON_DEPENDENT_EXPRs for FUNCTION_DECLs or TEMPLATE_DECLs.
+
+       PR c++/13968
+       * semantics.c (finish_id_expression): Do not return an
+       IDENTIFIER_NODE when lookup finds a VAR_DECL.
+
+       PR c++/13975
+       * parser.c (cp_parser_simple_declaration): When skipping to the
+       end of the statement swallow the terminating semicolon.
+
 2004-02-02  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/13113
index 1348b5095e32efa76d840b8d41cbae05b7d54865..2857468f20fe77ccfa3c1a0627f007ff08707348 100644 (file)
@@ -6506,6 +6506,9 @@ cp_parser_simple_declaration (cp_parser* parser,
          cp_parser_error (parser, "expected `,' or `;'");
          /* Skip tokens until we reach the end of the statement.  */
          cp_parser_skip_to_end_of_statement (parser);
+         /* If the next token is now a `;', consume it.  */
+         if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
+           cp_lexer_consume_token (parser->lexer);
          goto done;
        }
       /* After the first time around, a function-definition is not
index f0350423e7ce8f0f2b104c6fbf79a681b87a8a28..b8a02fbe47e0fd1e48d3e8d9624c9c3478184ba1 100644 (file)
@@ -12027,7 +12027,9 @@ build_non_dependent_expr (tree expr)
     return expr;
   /* Preserve OVERLOADs; the functions must be available to resolve
      types.  */
-  if (TREE_CODE (expr) == OVERLOAD)
+  if (TREE_CODE (expr) == OVERLOAD 
+      || TREE_CODE (expr) == FUNCTION_DECL
+      || TREE_CODE (expr) == TEMPLATE_DECL)
     return expr;
   /* Preserve string constants; conversions from string constants to
      "char *" are allowed, even though normally a "const char *"
index 4af197be85f7ff67351b91ad56c1dd8f6c6550a7..5b1b1ef4d1cbed7ee34e0a1693d0a3add90e442e 100644 (file)
@@ -2524,6 +2524,11 @@ finish_id_expression (tree id_expression,
          if (integral_constant_expression_p)
            *non_integral_constant_expression_p = true;
          *idk = CP_ID_KIND_UNQUALIFIED_DEPENDENT;
+         /* If we found a variable, then name lookup during the
+            instantiation will always resolve to the same VAR_DECL
+            (or an instantiation thereof).  */
+         if (TREE_CODE (decl) == VAR_DECL)
+           return decl;
          return id_expression;
        }
 
index 873e6bbc5f28d8d4ad4cafc4a3a9675ade36d656..a746adb2583828e0a3b8844656e7c4f48b86bb46 100644 (file)
@@ -1,3 +1,15 @@
+2004-02-03  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/13978
+       * g++.dg/template/koenig4.C: New test.
+
+       PR c++/13968
+       * g++.dg/template/crash17.C: New test.
+
+       PR c++/13975
+       * g++.dg/parse/error13.C: New test.
+       * g++.old-deja/g++.robertl/eb125.C: Tweak error messages.
+
 2004-02-03  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/20020503-1.c: Remove -mflat dg-options.
diff --git a/gcc/testsuite/g++.dg/template/crash17.C b/gcc/testsuite/g++.dg/template/crash17.C
new file mode 100644 (file)
index 0000000..9fa826b
--- /dev/null
@@ -0,0 +1,19 @@
+template <int I> 
+struct A {
+};
+
+template <typename T>
+struct B {
+  typedef typename T::type type;
+  static const type j = T::j;
+
+  A<j> b;
+};
+
+struct C {
+  typedef int type;
+  static const int j = 3;
+};
+
+int i = B<C>::j;
+
diff --git a/gcc/testsuite/g++.dg/template/koenig4.C b/gcc/testsuite/g++.dg/template/koenig4.C
new file mode 100644 (file)
index 0000000..31e41fc
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/13978
+
+namespace ns {
+  template <class TP> void func1(TP* t);
+  struct A {};
+}
+template < class TP >
+void func2() {
+  func1( new ns::A() );
+}
+
index 915fbe6794b27276f20dbed3a814c3cb7c59c53e..b06823685e426b1e7c471c24315b8c28d67458c2 100644 (file)
@@ -17,6 +17,6 @@ class test_square
 template <class BOX> void test(BOX *the_box)  // { dg-error "" } semicolon missing
     {x
     the_box->print();
-    }; // { dg-error "" }
+    };
 
 template void test<> (test_box *); // { dg-error "" }
index 47ae7ba5e950f888f820b95340b7ec6236c3c115..ac0da204031f89f8247a1c5999ee681339675bae 100644 (file)
@@ -4917,6 +4917,10 @@ build_common_tree_nodes (int signed_char)
   unsigned_intSI_type_node = make_unsigned_type (GET_MODE_BITSIZE (SImode));
   unsigned_intDI_type_node = make_unsigned_type (GET_MODE_BITSIZE (DImode));
   unsigned_intTI_type_node = make_unsigned_type (GET_MODE_BITSIZE (TImode));
+  
+  access_public_node = get_identifier ("public");
+  access_protected_node = get_identifier ("protected");
+  access_private_node = get_identifier ("private");
 }
 
 /* Call this function after calling build_common_tree_nodes and set_sizetype.
index a69678285ee669d48194163a4dcaf2f9af3f5869..3f97099ef62187b542310f0789cd408727aaa777 100644 (file)
@@ -1816,6 +1816,10 @@ enum tree_index
   TI_BITSIZE_ONE,
   TI_BITSIZE_UNIT,
 
+  TI_PUBLIC,
+  TI_PROTECTED,
+  TI_PRIVATE,
+
   TI_BOOLEAN_FALSE,
   TI_BOOLEAN_TRUE,
 
@@ -1901,9 +1905,9 @@ extern GTY(()) tree global_trees[TI_MAX];
 #define bitsize_unit_node              global_trees[TI_BITSIZE_UNIT]
 
 /* Base access nodes.  */
-#define access_public_node             NULL_TREE
-#define access_protected_node          size_zero_node
-#define access_private_node            size_one_node
+#define access_public_node             global_trees[TI_PUBLIC]
+#define access_protected_node          global_trees[TI_PROTECTED]
+#define access_private_node            global_trees[TI_PRIVATE]
 
 #define null_pointer_node              global_trees[TI_NULL_POINTER]