cp-tree.def (USING_STMT): New statement node.
cp: * 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. testsuite: * g++.old-deja/g++.ns/template17.C: New test. From-SVN: r41724
This commit is contained in:
parent
6496a589df
commit
9da99f7d83
@ -1,3 +1,12 @@
|
||||
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.
|
||||
|
@ -171,6 +171,9 @@ DEFTREECODE (TYPEOF_TYPE, "typeof_type", 't', 0)
|
||||
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)
|
||||
|
||||
|
@ -3051,6 +3051,8 @@ extern int flag_new_for_scope;
|
||||
#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)
|
||||
@ -3058,7 +3060,6 @@ extern int flag_new_for_scope;
|
||||
#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)))
|
||||
|
@ -5204,18 +5204,23 @@ do_using_directive (namespace)
|
||||
{
|
||||
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);
|
||||
|
@ -6886,7 +6886,7 @@ tsubst_copy (t, args, complain, in_decl)
|
||||
|
||||
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. */
|
||||
@ -7211,6 +7211,12 @@ tsubst_expr (t, args, complain, in_decl)
|
||||
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;
|
||||
|
@ -2220,6 +2220,9 @@ cp_expand_stmt (t)
|
||||
genrtl_named_return_value ();
|
||||
break;
|
||||
|
||||
case USING_STMT:
|
||||
break;
|
||||
|
||||
default:
|
||||
my_friendly_abort (19990810);
|
||||
break;
|
||||
|
@ -1,3 +1,7 @@
|
||||
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.
|
||||
|
37
gcc/testsuite/g++.old-deja/g++.ns/template17.C
Normal file
37
gcc/testsuite/g++.old-deja/g++.ns/template17.C
Normal file
@ -0,0 +1,37 @@
|
||||
// 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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user