+2004-03-18 Mark Mitchell <mark@codesourcery.com>
+
+ * c-common.c (pointer_int_sum): Do not complain about using
+ pointers to pointers-to-members.
+
2004-03-18 Kazu Hirata <kazu@cs.umass.edu>
* system.h (MD_ASM_CLOBBERS): Move to "Old target macros that
pedwarn ("pointer to member function used in arithmetic");
size_exp = integer_one_node;
}
- else if (TREE_CODE (TREE_TYPE (result_type)) == OFFSET_TYPE)
- {
- if (pedantic || warn_pointer_arith)
- pedwarn ("pointer to a member used in arithmetic");
- size_exp = integer_one_node;
- }
else
size_exp = size_in_bytes (TREE_TYPE (result_type));
+2004-03-18 Mark Mitchell <mark@codesourcery.com>
+
+ * call.c (build_conditional_expr): Do not call force_rvalue for
+ operands of void_type when the conditional expression itself has
+ void type.
+ * name-lookup.c (pushdecl): Don't consider a declaration of a
+ function named "main" to be an overload of a type named "main".
+ * parser.c (cp_parser_template_name): Perform name lookup when the
+ template name is proceeded by "template" if the qualifying scope
+ is non-dependent.
+ * typeck.c (composite_pointer_type_r): Correctly handle
+ pointer-to-member types.
+ (build_const_cast): Likewise.
+
2004-03-18 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* cp-tree.def (TEMPLATE_TYPE_PARM, TYPEOF_TYPE): Update comments.
type of the other and is an rvalue.
--Both the second and the third operands have type void; the
- result is of type void and is an rvalue. */
+ result is of type void and is an rvalue.
+
+ We must avoid calling force_rvalue for expressions of type
+ "void" because it will complain that their value is being
+ used. */
if (TREE_CODE (arg2) == THROW_EXPR
&& TREE_CODE (arg3) != THROW_EXPR)
{
- arg3 = force_rvalue (arg3);
+ if (!VOID_TYPE_P (arg3_type))
+ arg3 = force_rvalue (arg3);
arg3_type = TREE_TYPE (arg3);
result_type = arg3_type;
}
else if (TREE_CODE (arg2) != THROW_EXPR
&& TREE_CODE (arg3) == THROW_EXPR)
{
- arg2 = force_rvalue (arg2);
+ if (!VOID_TYPE_P (arg2_type))
+ arg2 = force_rvalue (arg2);
arg2_type = TREE_TYPE (arg2);
result_type = arg2_type;
}
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
}
- else if (DECL_MAIN_P (x))
+ else if (DECL_MAIN_P (x) && TREE_CODE (t) == FUNCTION_DECL)
{
/* A redeclaration of main, but not a duplicate of the
previous one.
*is_identifier = true;
return identifier;
}
- if (template_keyword_p)
+
+ /* If the "template" keyword is present, then there is generally
+ no point in doing name-lookup, so we just return IDENTIFIER.
+ But, if the qualifying scope is non-dependent then we can
+ (and must) do name-lookup normally. */
+ if (template_keyword_p
+ && (!parser->scope
+ || (TYPE_P (parser->scope)
+ && dependent_type_p (parser->scope))))
return identifier;
}
result_type = cp_build_qualified_type (result_type,
(cp_type_quals (pointee1)
| cp_type_quals (pointee2)));
- result_type = build_pointer_type (result_type);
/* If the original types were pointers to members, so is the
result. */
if (TYPE_PTR_TO_MEMBER_P (t1))
result_type = build_ptrmem_type (TYPE_PTRMEM_CLASS_TYPE (t1),
result_type);
}
+ else
+ result_type = build_pointer_type (result_type);
/* Merge the attributes. */
attributes = (*targetm.merge_type_attributes) (t1, t2);
return t;
}
- if (!POINTER_TYPE_P (type))
+ if (!POINTER_TYPE_P (type) && !TYPE_PTRMEM_P (type))
error ("invalid use of const_cast with type `%T', which is not a pointer, reference, nor a pointer-to-data-member type", type);
else if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
{
+2004-03-18 Mark Mitchell <mark@codesourcery.com>
+
+ * g++.dg/expr/cond5.C: New test.
+ * g++.dg/expr/constcast1.C: Likewise.
+ * g++.dg/expr/ptrmem2.C: Likewise.
+ * g++.dg/expr/ptrmem3.C: Likewise.
+ * g++.dg/lookup/main1.C: Likewise.
+ * g++.dg/template/lookup6.C: Likewise.
+
2004-03-18 Mark Mitchell <mark@codesourcery.com>
* gcc.dg/local1.c: New test.
--- /dev/null
+struct main {};
+
+int main () {}
--- /dev/null
+struct S
+{
+ template<typename T> static void g();
+};
+
+template<typename T>
+void f() { return S::template g<T>(); }
+
+void g() {
+ f<int>();
+}