aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-02-03 16:53:27 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-02-03 16:53:27 +0000
commit5a98fa7bdb847dc92fdbeddf4dfcff51835aca48 (patch)
treeaad012333fc4dc0d216db7ad633eef56c2ea58ea /gcc
parent0263e6bf3c7ccd1cccbc18b5e6cef273878d9e7f (diff)
downloadgcc-5a98fa7bdb847dc92fdbeddf4dfcff51835aca48.zip
gcc-5a98fa7bdb847dc92fdbeddf4dfcff51835aca48.tar.gz
gcc-5a98fa7bdb847dc92fdbeddf4dfcff51835aca48.tar.bz2
re PR c++/13975 (ICE on misplaced visibility specifier.)
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/cp/ChangeLog14
-rw-r--r--gcc/cp/parser.c3
-rw-r--r--gcc/cp/pt.c4
-rw-r--r--gcc/cp/semantics.c5
-rw-r--r--gcc/testsuite/ChangeLog12
-rw-r--r--gcc/testsuite/g++.dg/template/crash17.C19
-rw-r--r--gcc/testsuite/g++.dg/template/koenig4.C12
-rw-r--r--gcc/testsuite/g++.old-deja/g++.robertl/eb125.C2
-rw-r--r--gcc/tree.c4
-rw-r--r--gcc/tree.h10
11 files changed, 91 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 212e60f..eedaab5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9c3d573..221fbe6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 1348b50..2857468 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f035042..b8a02fb 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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 *"
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 4af197b..5b1b1ef4 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 873e6bb..a746adb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..9fa826b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/crash17.C
@@ -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
index 0000000..31e41fc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/koenig4.C
@@ -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() );
+}
+
diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb125.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb125.C
index 915fbe6..b068236 100644
--- a/gcc/testsuite/g++.old-deja/g++.robertl/eb125.C
+++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb125.C
@@ -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 "" }
diff --git a/gcc/tree.c b/gcc/tree.c
index 47ae7ba..ac0da20 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -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.
diff --git a/gcc/tree.h b/gcc/tree.h
index a696782..3f97099 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -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]