mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-10 18:20:51 +08:00
c-common.c (pointer_int_sum): Do not complain about using pointers to pointers-to-members.
* c-common.c (pointer_int_sum): Do not complain about using pointers to pointers-to-members. * 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. * 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. From-SVN: r79663
This commit is contained in:
parent
c3690d79a8
commit
9d363a56a8
@ -1,3 +1,8 @@
|
||||
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
|
||||
|
@ -2484,12 +2484,6 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
|
||||
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));
|
||||
|
||||
|
@ -1,3 +1,17 @@
|
||||
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.
|
||||
|
@ -3178,18 +3178,24 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
|
||||
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;
|
||||
}
|
||||
|
@ -706,7 +706,7 @@ pushdecl (tree x)
|
||||
|
||||
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.
|
||||
|
@ -8203,7 +8203,15 @@ cp_parser_template_name (cp_parser* parser,
|
||||
*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;
|
||||
}
|
||||
|
||||
|
@ -443,7 +443,6 @@ composite_pointer_type_r (tree t1, tree t2, const char* location)
|
||||
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))
|
||||
@ -456,6 +455,8 @@ composite_pointer_type_r (tree t1, tree t2, const char* location)
|
||||
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);
|
||||
@ -4726,7 +4727,7 @@ build_const_cast (tree type, tree expr)
|
||||
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)
|
||||
{
|
||||
|
@ -1,3 +1,12 @@
|
||||
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.
|
||||
|
3
gcc/testsuite/g++.dg/lookup/main1.C
Normal file
3
gcc/testsuite/g++.dg/lookup/main1.C
Normal file
@ -0,0 +1,3 @@
|
||||
struct main {};
|
||||
|
||||
int main () {}
|
11
gcc/testsuite/g++.dg/template/lookup6.C
Normal file
11
gcc/testsuite/g++.dg/template/lookup6.C
Normal file
@ -0,0 +1,11 @@
|
||||
struct S
|
||||
{
|
||||
template<typename T> static void g();
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void f() { return S::template g<T>(); }
|
||||
|
||||
void g() {
|
||||
f<int>();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user