+2001-05-01 Nathan Sidwell <nathan@codesourcery.com>
+
+ * cp-tree.def (USING_STMT): New statement node.
+ * cp-tree.h (USING_STMT_NAMESPACE): New macro.
+ * decl2.c (do_using_directive): Add USING_STMT to statement
+ tree. Don't emit errors when processing template decl.
+ * pt.c (tsubst_expr, USING_STMT case): New case.
+ * semantics.c (cp_expand_stmt, USING_STMT case): New case.
+
2001-05-01 Nathan Sidwell <nathan@codesourcery.com>
* call.c (build_new_op): Convert args from reference here.
This is not an alias, but is later expanded into multiple aliases. */
DEFTREECODE (USING_DECL, "using_decl", 'd', 0)
+/* A using directive. The operand is USING_STMT_NAMESPACE. */
+DEFTREECODE (USING_STMT, "using_directive", 'e', 1)
+
/* An un-parsed default argument. Looks like an IDENTIFIER_NODE. */
DEFTREECODE (DEFAULT_ARG, "default_arg", 'x', 2)
#define EH_SPEC_STMTS(NODE) TREE_OPERAND (EH_SPEC_BLOCK_CHECK (NODE), 0)
#define EH_SPEC_RAISES(NODE) TREE_OPERAND (EH_SPEC_BLOCK_CHECK (NODE), 1)
+#define USING_STMT_NAMESPACE(NODE) TREE_OPERAND (USING_STMT_CHECK (NODE), 0)
+
/* Nonzero if this try block is a function try block. */
#define FN_TRY_BLOCK_P(NODE) TREE_LANG_FLAG_3 (TRY_BLOCK_CHECK (NODE))
#define HANDLER_PARMS(NODE) TREE_OPERAND (HANDLER_CHECK (NODE), 0)
#define SUBOBJECT_CLEANUP(NODE) TREE_OPERAND (SUBOBJECT_CHECK (NODE), 0)
#define START_CATCH_TYPE(NODE) TREE_TYPE (START_CATCH_STMT_CHECK (NODE))
-
/* Nonzero if this CTOR_STMT is for the beginning of a constructor. */
#define CTOR_BEGIN_P(NODE) \
(TREE_LANG_FLAG_0 (CTOR_STMT_CHECK (NODE)))
{
if (namespace == fake_std_node)
return;
+ 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. */
- cp_error ("namespace `%T' undeclared", namespace);
+ if (!processing_template_decl)
+ cp_error ("namespace `%T' undeclared", namespace);
return;
}
if (TREE_CODE (namespace) != NAMESPACE_DECL)
{
- cp_error ("`%T' is not a namespace", namespace);
+ if (!processing_template_decl)
+ cp_error ("`%T' is not a namespace", namespace);
return;
}
namespace = ORIGINAL_NAMESPACE (namespace);
case LOOKUP_EXPR:
{
- /* We must tsbust into a LOOKUP_EXPR in case the names to
+ /* We must tsubst into a LOOKUP_EXPR in case the names to
which it refers is a conversion operator; in that case the
name will change. We avoid making unnecessary copies,
however. */
args, complain, in_decl));
break;
+ case USING_STMT:
+ prep_stmt (t);
+ do_using_directive (tsubst_expr (USING_STMT_NAMESPACE (t),
+ args, complain, in_decl));
+ break;
+
case DECL_STMT:
{
tree decl;
genrtl_named_return_value ();
break;
+ case USING_STMT:
+ break;
+
default:
my_friendly_abort (19990810);
break;
+2001-05-01 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.old-deja/g++.ns/template17.C: New test.
+
2001-05-01 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.pt/ref4.C: New test.
--- /dev/null
+// Build don't link:
+//
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 29 Apr 2001 <nathan@codesourcery.com>
+
+// Bug 2258. We failed to implement using directives inside template
+// functions. This makes us regress now that ::std is real.
+
+namespace thing
+{
+ template <typename T> T end2 (T);
+}
+namespace whatever
+{
+}
+
+template <typename T> void fn (T, T (*)(T));
+
+template <class T> void mycout(const T& data)
+{
+ using namespace thing;
+ using namespace whatever;
+
+ fn (data, end2);
+ fn (data, end3);
+}
+
+namespace whatever
+{
+ template <typename T> T end3 (T);
+}
+
+int main()
+{
+ double data = 5.0;
+ mycout(data);
+}