diff options
author | Mark Mitchell <mark@codesourcery.com> | 2004-03-19 01:35:01 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2004-03-19 01:35:01 +0000 |
commit | 9d363a56a8ff6587f8d32ea380b55fea77ea5f13 (patch) | |
tree | ff8a9efb7d2b4a67b0c26125354dd012254824f4 | |
parent | c3690d79a8c861f10b77954379e03dd96807a409 (diff) | |
download | gcc-9d363a56a8ff6587f8d32ea380b55fea77ea5f13.zip gcc-9d363a56a8ff6587f8d32ea380b55fea77ea5f13.tar.gz gcc-9d363a56a8ff6587f8d32ea380b55fea77ea5f13.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-common.c | 6 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/cp/call.c | 12 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 2 | ||||
-rw-r--r-- | gcc/cp/parser.c | 10 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/main1.C | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/lookup6.C | 11 |
10 files changed, 64 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d118f05..c33d57b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/c-common.c b/gcc/c-common.c index 057ebee..49c9ccf 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -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)); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 00e5066..1052abe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 62182f3..7a3039b 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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; } diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index ce101de..1589682 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -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. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index db40252..0dc63cd 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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; } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 10103c8..e353d3f 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b7ff475..be760c8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,14 @@ 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. * gcc.dg/debug/dwarf2/c99-typedef1.c: New test. diff --git a/gcc/testsuite/g++.dg/lookup/main1.C b/gcc/testsuite/g++.dg/lookup/main1.C new file mode 100644 index 0000000..1de8342 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/main1.C @@ -0,0 +1,3 @@ +struct main {}; + +int main () {} diff --git a/gcc/testsuite/g++.dg/template/lookup6.C b/gcc/testsuite/g++.dg/template/lookup6.C new file mode 100644 index 0000000..2ca6dcc --- /dev/null +++ b/gcc/testsuite/g++.dg/template/lookup6.C @@ -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>(); +} |