+2005-03-05 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/19311
+ * init.c (build_offset_ref): Don't build non-dependent SCOPE_REF.
+ * pt.c (build_non_dependent_expr): Don't build NON_DEPENDENT_EXPR
+ for OFFSET_TYPE.
+ * typeck.c (build_x_unary_op): Don't build non-dependent SCOPE_REF.
+ Also set PTRMEM_OK_P for NON_DEPENDENT_EXPR.
+ (build_unary_op): Handle building ADDR_EXPR of OFFSET_REF inside
+ template.
+
2005-03-02 Alexandre Oliva <aoliva@redhat.com>
* name-lookup.c (push_overloaded_decl): Don't error if the new
if (type_dependent_expression_p (xarg))
return build_min_nt (code, xarg, NULL_TREE);
- /* For non-dependent pointer-to-member, the SCOPE_REF will be
- processed during template substitution. Just compute the
- right type here and build an ADDR_EXPR around it for
- diagnostics. */
- if (code == ADDR_EXPR && TREE_CODE (xarg) == SCOPE_REF)
- {
- tree type;
- if (TREE_TYPE (xarg) == unknown_type_node)
- type = unknown_type_node;
- else if (TREE_CODE (TREE_TYPE (xarg)) == FUNCTION_TYPE)
- type = build_pointer_type (TREE_TYPE (xarg));
- else
- type = build_ptrmem_type (TREE_OPERAND (xarg, 0),
- TREE_TYPE (xarg));
- return build_min (code, type, xarg, NULL_TREE);
- }
-
xarg = build_non_dependent_expr (xarg);
}
else if (TREE_CODE (xarg) == TARGET_EXPR)
warning ("taking address of temporary");
exp = build_unary_op (ADDR_EXPR, xarg, 0);
- if (TREE_CODE (exp) == ADDR_EXPR)
- PTRMEM_OK_P (exp) = ptrmem;
}
if (processing_template_decl && exp != error_mark_node)
- return build_min_non_dep (code, exp, orig_expr,
- /*For {PRE,POST}{INC,DEC}REMENT_EXPR*/NULL_TREE);
+ exp = build_min_non_dep (code, exp, orig_expr,
+ /*For {PRE,POST}{INC,DEC}REMENT_EXPR*/NULL_TREE);
+ if (TREE_CODE (exp) == ADDR_EXPR)
+ PTRMEM_OK_P (exp) = ptrmem;
return exp;
}
is an error. */
else if (TREE_CODE (argtype) != FUNCTION_TYPE
&& TREE_CODE (argtype) != METHOD_TYPE
+ && TREE_CODE (arg) != OFFSET_REF
&& !lvalue_or_else (arg, lv_addressof))
return error_mark_node;
expression so we can just form an ADDR_EXPR with the
correct type. */
|| processing_template_decl)
- addr = build_address (arg);
+ {
+ addr = build_address (arg);
+ if (TREE_CODE (arg) == OFFSET_REF)
+ PTRMEM_OK_P (addr) = PTRMEM_OK_P (arg);
+ }
else if (TREE_CODE (TREE_OPERAND (arg, 1)) == BASELINK)
{
tree fn = BASELINK_FUNCTIONS (TREE_OPERAND (arg, 1));
--- /dev/null
+// { dg-do compile }
+
+// Origin: Jakub Jelinek <jakub@gcc.gnu.org>
+// Wolfgang Bangerth <bangerth@ticam.utexas.edu>
+
+// PR c++/19311: Non-dependent address to member as function argument.
+
+template <class R, class T> void foo (R (T::*x) ());
+template <class R, class T, class C> void foo (R (T::*x) (C));
+
+template<int> struct I {
+ int o ();
+ int o () const;
+};
+
+template <int> void bar (void) {
+ foo <int, I<1> > (&I<1>::o);
+}