From 2c584053e7a50135ab299115a5d7b909bd65355f Mon Sep 17 00:00:00 2001 From: mmitchel Date: Tue, 3 Feb 2004 16:53:27 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@77176 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 11 +++++++++++ gcc/cp/ChangeLog | 14 ++++++++++++++ gcc/cp/parser.c | 3 +++ gcc/cp/pt.c | 4 +++- gcc/cp/semantics.c | 5 +++++ gcc/testsuite/ChangeLog | 12 ++++++++++++ gcc/testsuite/g++.dg/template/crash17.C | 19 +++++++++++++++++++ gcc/testsuite/g++.dg/template/koenig4.C | 12 ++++++++++++ gcc/testsuite/g++.old-deja/g++.robertl/eb125.C | 2 +- gcc/tree.c | 4 ++++ gcc/tree.h | 10 +++++++--- 11 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/crash17.C create mode 100644 gcc/testsuite/g++.dg/template/koenig4.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 212e60fe486..eedaab5d58d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2004-02-03 Mark Mitchell + + 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 * config/ia64/ia64.h (MASK_INLINE_INT_DIV_LAT): Change value. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9c3d5732edb..221fbe627a9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,17 @@ +2004-02-03 Mark Mitchell + + 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 PR c++/13113 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 1348b5095e3..2857468f20f 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 f0350423e7c..b8a02fbe47e 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 4af197be85f..5b1b1ef4d1c 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 873e6bbc5f2..a746adb2583 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2004-02-03 Mark Mitchell + + 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 * 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 00000000000..9fa826b999d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash17.C @@ -0,0 +1,19 @@ +template +struct A { +}; + +template +struct B { + typedef typename T::type type; + static const type j = T::j; + + A b; +}; + +struct C { + typedef int type; + static const int j = 3; +}; + +int i = B::j; + diff --git a/gcc/testsuite/g++.dg/template/koenig4.C b/gcc/testsuite/g++.dg/template/koenig4.C new file mode 100644 index 00000000000..31e41fcf97f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/koenig4.C @@ -0,0 +1,12 @@ +// PR c++/13978 + +namespace ns { + template 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 915fbe6794b..b06823685e4 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 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 47ae7ba5e95..ac0da204031 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 a69678285ee..3f97099ef62 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] -- 2.11.0