+2003-09-02 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/11808
+ * cp-tree.h (KOENIG_LOOKUP_P): New macro.
+ (finish_call_expr): Change prototype.
+ * parser.c (cp_parser_postfix_expression): Adjust call to
+ finish_call_expr.
+ * pt.c (tsubst_copy_and_build): Use KOENIG_LOOKUP_P.
+ * semantics.c (finish_call_expr): Add koenig_p parameter.
+
2003-09-01 Mark Mitchell <mark@codesourcery.com>
PR c++/12114
PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF)
PARMLIST_ELLIPSIS_P (in PARMLIST)
DECL_PRETTY_FUNCTION_P (in VAR_DECL)
+ KOENIG_LOOKUP_P (in CALL_EXPR)
1: IDENTIFIER_VIRTUAL_P.
TI_PENDING_TEMPLATE_FLAG.
TEMPLATE_PARMS_FOR_INLINE.
#define DELETE_EXPR_USE_GLOBAL(NODE) TREE_LANG_FLAG_0 (NODE)
#define DELETE_EXPR_USE_VEC(NODE) TREE_LANG_FLAG_1 (NODE)
+/* In a CALL_EXPR appearing in a template, true if Koenig lookup
+ should be performed at instantiation time. */
+#define KOENIG_LOOKUP_P(NODE) TREE_LANG_FLAG_0(NODE)
+
/* Nonzero if this AGGR_INIT_EXPR provides for initialization via a
constructor call, rather than an ordinary function call. */
#define AGGR_INIT_VIA_CTOR_P(NODE) \
extern tree finish_stmt_expr_expr (tree);
extern tree finish_stmt_expr (tree, bool);
extern tree perform_koenig_lookup (tree, tree);
-extern tree finish_call_expr (tree, tree, bool);
+extern tree finish_call_expr (tree, tree, bool, bool);
extern tree finish_increment_expr (tree, enum tree_code);
extern tree finish_this_expr (void);
extern tree finish_object_call_expr (tree, tree, tree);
case CPP_OPEN_PAREN:
/* postfix-expression ( expression-list [opt] ) */
{
+ bool koenig_p;
tree args = (cp_parser_parenthesized_expression_list
(parser, false, /*non_constant_p=*/NULL));
parser->non_constant_expression_p = true;
}
+ koenig_p = false;
if (idk == CP_ID_KIND_UNQUALIFIED)
{
if (args
&& (is_overloaded_fn (postfix_expression)
|| DECL_P (postfix_expression)
|| TREE_CODE (postfix_expression) == IDENTIFIER_NODE))
- postfix_expression
- = perform_koenig_lookup (postfix_expression, args);
+ {
+ koenig_p = true;
+ postfix_expression
+ = perform_koenig_lookup (postfix_expression, args);
+ }
else if (TREE_CODE (postfix_expression) == IDENTIFIER_NODE)
postfix_expression
= unqualified_fn_lookup_error (postfix_expression);
function. */
postfix_expression
= finish_call_expr (postfix_expression, args,
- /*disallow_virtual=*/true);
+ /*disallow_virtual=*/true,
+ koenig_p);
else
/* All other function calls. */
postfix_expression
= finish_call_expr (postfix_expression, args,
- /*disallow_virtual=*/false);
+ /*disallow_virtual=*/false,
+ koenig_p);
/* The POSTFIX_EXPRESSION is certainly no longer an id. */
idk = CP_ID_KIND_NONE;
bool koenig_p;
function = TREE_OPERAND (t, 0);
- /* To determine whether or not we should perform Koenig lookup
- we must look at the form of the FUNCTION. */
- koenig_p = !(/* Koenig lookup does not apply to qualified
- names. */
- TREE_CODE (function) == SCOPE_REF
- /* Or to references to members of classes. */
- || TREE_CODE (function) == COMPONENT_REF
- /* If it is a FUNCTION_DECL or a baselink, then
- the name was already resolved when the
- template was parsed. */
- || TREE_CODE (function) == FUNCTION_DECL
- || TREE_CODE (function) == BASELINK);
+ /* When we parsed the expression, we determined whether or
+ not Koenig lookup should be performed. */
+ koenig_p = KOENIG_LOOKUP_P (t);
if (TREE_CODE (function) == SCOPE_REF)
{
qualified_p = true;
function = tsubst_copy_and_build (function, args, complain,
in_decl,
!qualified_p);
+ if (BASELINK_P (function))
+ qualified_p = true;
}
call_args = RECUR (TREE_OPERAND (t, 1));
- if (BASELINK_P (function))
- qualified_p = 1;
-
if (koenig_p
- && TREE_CODE (function) != TEMPLATE_ID_EXPR
&& (is_overloaded_fn (function)
|| DECL_P (function)
|| TREE_CODE (function) == IDENTIFIER_NODE))
+ function = perform_koenig_lookup (function, call_args);
+
+ if (TREE_CODE (function) == IDENTIFIER_NODE)
{
- if (call_args)
- function = perform_koenig_lookup (function, call_args);
- else if (TREE_CODE (function) == IDENTIFIER_NODE)
- function = unqualified_name_lookup_error (function);
+ unqualified_name_lookup_error (function);
+ return error_mark_node;
}
/* Remember that there was a reference to this entity. */
call_args, NULL_TREE,
qualified_p ? LOOKUP_NONVIRTUAL : LOOKUP_NORMAL));
return finish_call_expr (function, call_args,
- /*disallow_virtual=*/qualified_p);
+ /*disallow_virtual=*/qualified_p,
+ koenig_p);
}
case COND_EXPR:
Returns code for the call. */
tree
-finish_call_expr (tree fn, tree args, bool disallow_virtual)
+finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p)
{
tree result;
tree orig_fn;
{
if (type_dependent_expression_p (fn)
|| any_type_dependent_arguments_p (args))
- return build_nt (CALL_EXPR, fn, args);
+ {
+ result = build_nt (CALL_EXPR, fn, args);
+ KOENIG_LOOKUP_P (result) = koenig_p;
+ return result;
+ }
if (!BASELINK_P (fn)
&& TREE_CODE (fn) != PSEUDO_DTOR_EXPR
&& TREE_TYPE (fn) != unknown_type_node)
result = build_function_call (fn, args);
if (processing_template_decl)
- return build (CALL_EXPR, TREE_TYPE (result), orig_fn, orig_args);
+ {
+ result = build (CALL_EXPR, TREE_TYPE (result), orig_fn, orig_args);
+ KOENIG_LOOKUP_P (result) = koenig_p;
+ }
return result;
}
+2003-09-02 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/11808
+ * g++.dg/expr/call1.C: New test.
+
2003-09-01 Mark Mitchell <mark@codesourcery.com>
PR c++/12114
--- /dev/null
+namespace NS_1 {
+ struct A {};
+ struct foo {};
+}
+
+namespace NS_2 {
+ template <typename T> void foo(T);
+
+ template <typename T>
+ void bar() {
+ NS_1::A a;
+ NS_2::foo(a);
+ }
+
+ template void bar<int>();
+}