aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>2005-08-30 16:22:00 +0000
committerVolker Reichelt <reichelt@gcc.gnu.org>2005-08-30 16:22:00 +0000
commit166206ce70f9c9ef4e4f418e958ea635b953cf1c (patch)
tree149d5122acf1aea4600cd84ba169da49ef609206 /gcc
parent7a98d47cf7832ce369db72c587b9ed0d48f21755 (diff)
downloadgcc-166206ce70f9c9ef4e4f418e958ea635b953cf1c.zip
gcc-166206ce70f9c9ef4e4f418e958ea635b953cf1c.tar.gz
gcc-166206ce70f9c9ef4e4f418e958ea635b953cf1c.tar.bz2
re PR c++/23586 (Bad diagnostic for invalid namespace-name)
PR c++/23586 * parser.c (cp_parser_namespace_name): Move diagnostic for invalid namespace-name to here from ... * name-lookup.c (do_namespace_alias): ... here and ... (do_using_directive): ... here. Remove dead code. From-SVN: r103643
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/name-lookup.c33
-rw-r--r--gcc/cp/parser.c2
3 files changed, 20 insertions, 23 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4051336..cc10775 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2005-08-30 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+ PR c++/23586
+ * parser.c (cp_parser_namespace_name): Move diagnostic for
+ invalid namespace-name to here from ...
+ * name-lookup.c (do_namespace_alias): ... here and ...
+ (do_using_directive): ... here. Remove dead code.
+
2005-08-28 Mark Mitchell <mark@codesourcery.com>
PR c++/23099
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 7270a9d..f936a86 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3037,12 +3037,10 @@ namespace_ancestor (tree ns1, tree ns2)
void
do_namespace_alias (tree alias, tree namespace)
{
- if (TREE_CODE (namespace) != NAMESPACE_DECL)
- {
- /* The parser did not find it, so it's not there. */
- error ("unknown namespace %qD", namespace);
- return;
- }
+ if (namespace == error_mark_node)
+ return;
+
+ gcc_assert (TREE_CODE (namespace) == NAMESPACE_DECL);
namespace = ORIGINAL_NAMESPACE (namespace);
@@ -3191,26 +3189,15 @@ do_using_directive (tree namespace)
{
tree context = NULL_TREE;
+ if (namespace == error_mark_node)
+ return;
+
+ gcc_assert (TREE_CODE (namespace) == NAMESPACE_DECL);
+
if (building_stmt_tree ())
add_stmt (build_stmt (USING_STMT, namespace));
-
- /* using namespace A::B::C; */
- if (TREE_CODE (namespace) == SCOPE_REF)
- namespace = TREE_OPERAND (namespace, 1);
- if (TREE_CODE (namespace) == IDENTIFIER_NODE)
- {
- /* Lookup in lexer did not find a namespace. */
- if (!processing_template_decl)
- error ("namespace %qT undeclared", namespace);
- return;
- }
- if (TREE_CODE (namespace) != NAMESPACE_DECL)
- {
- if (!processing_template_decl)
- error ("%qT is not a namespace", namespace);
- return;
- }
namespace = ORIGINAL_NAMESPACE (namespace);
+
if (!toplevel_bindings_p ())
{
push_using_directive (namespace);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 6712f00..bebdfcb 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -10254,6 +10254,8 @@ cp_parser_namespace_name (cp_parser* parser)
if (namespace_decl == error_mark_node
|| TREE_CODE (namespace_decl) != NAMESPACE_DECL)
{
+ if (!cp_parser_uncommitted_to_tentative_parse_p (parser))
+ error ("%qD is not a namespace-name", identifier);
cp_parser_error (parser, "expected namespace-name");
namespace_decl = error_mark_node;
}