diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-11-02 18:29:26 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-11-02 18:29:26 +0000 |
commit | 9918e7966c0d51e25b14a99adf87e2fbbe97c2e0 (patch) | |
tree | 3b70db062b6d1f096f376d65783b7e331d9a1514 /gcc | |
parent | dfa65d3fd1bfe62e2c831f7accf67855219b917f (diff) | |
download | gcc-9918e7966c0d51e25b14a99adf87e2fbbe97c2e0.zip gcc-9918e7966c0d51e25b14a99adf87e2fbbe97c2e0.tar.gz gcc-9918e7966c0d51e25b14a99adf87e2fbbe97c2e0.tar.bz2 |
[C++ PATCH] overloaded operator fns [8/N]
https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00095.html
* cp-tree.h (IDENTIFIER_NEWDEL_OP_P): Restore, adjust.
(IDENTIFIER_NEW_OP_P): New.
* decl.c (grokdeclarator): Restore IDENTIFIER_NEWDEL_OP_P use.
* pt.c (push_template_decl_real): Likewise.
* typeck.c (check_return_expr): Use IDENTIFIER_NEW_OP_P.
From-SVN: r254350
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 11 | ||||
-rw-r--r-- | gcc/cp/decl.c | 7 | ||||
-rw-r--r-- | gcc/cp/pt.c | 4 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 4 |
5 files changed, 26 insertions, 16 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7a7a589..f1dec17 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2017-11-02 Nathan Sidwell <nathan@acm.org> + * cp-tree.h (IDENTIFIER_NEWDEL_OP_P): Restore, adjust. + (IDENTIFIER_NEW_OP_P): New. + * decl.c (grokdeclarator): Restore IDENTIFIER_NEWDEL_OP_P use. + * pt.c (push_template_decl_real): Likewise. + * typeck.c (check_return_expr): Use IDENTIFIER_NEW_OP_P. + PR c++/82710 * decl.c (grokdeclarator): Don't warn when parens protect a return type from a qualified name. @@ -8,16 +14,16 @@ * cp-tree.h (enum cp_identifier_kind): Delete cik_newdel_op. Renumber and reserve udlit value. - (IDENTIFIER_NEWDEL_OP): Delete. - (IDENTIFIER_OVL_OP): New. - (IDENTIFIER_ASSIGN_OP): Adjust. - (IDENTIFIER_CONV_OP): Adjust. + (IDENTIFIER_NEWDEL_OP_P): Delete. + (IDENTIFIER_OVL_OP_P): New. + (IDENTIFIER_ASSIGN_OP_P): Adjust. + (IDENTIFIER_CONV_OP_P): Adjust. (IDENTIFIER_OVL_OP_INFO): Adjust. (IDENTIFIER_OVL_OP_FLAGS): New. * decl.c (grokdeclarator): Use IDENTIFIER_OVL_OP_FLAGS. * lex.c (get_identifier_kind_name): Adjust. (init_operators): Don't special case new/delete ops. - * mangle.c (write_unqualified_id): Use IDENTIFIER_OVL_OP. + * mangle.c (write_unqualified_id): Use IDENTIFIER_OVL_OP_P. * pt.c (push_template_decl_real): Use IDENTIFIER_OVL_OP_FLAGS. * typeck.c (check_return_expr): Likewise. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 1de32de..65f1fae 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1070,6 +1070,17 @@ enum cp_identifier_kind { & IDENTIFIER_KIND_BIT_1 (NODE) \ & (!IDENTIFIER_KIND_BIT_0 (NODE))) +/* True if this identifier is a new or delete operator. */ +#define IDENTIFIER_NEWDEL_OP_P(NODE) \ + (IDENTIFIER_OVL_OP_P (NODE) \ + && IDENTIFIER_OVL_OP_FLAGS (NODE) & OVL_OP_FLAG_ALLOC) + +/* True if this identifier is a new operator. */ +#define IDENTIFIER_NEW_OP_P(NODE) \ + (IDENTIFIER_OVL_OP_P (NODE) \ + && (IDENTIFIER_OVL_OP_FLAGS (NODE) \ + & (OVL_OP_FLAG_ALLOC | OVL_OP_FLAG_DELETE)) == OVL_OP_FLAG_ALLOC) + /* Access a C++-specific index for identifier NODE. Used to optimize operator mappings etc. */ #define IDENTIFIER_CP_INDEX(NODE) \ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 62bd3da..7c6f857 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11751,8 +11751,7 @@ grokdeclarator (const cp_declarator *declarator, if (ctype && TREE_CODE (type) == FUNCTION_TYPE && staticp < 2 && !(identifier_p (unqualified_id) - && IDENTIFIER_OVL_OP_P (unqualified_id) - && (IDENTIFIER_OVL_OP_FLAGS (unqualified_id) & OVL_OP_FLAG_ALLOC))) + && IDENTIFIER_NEWDEL_OP_P (unqualified_id))) { cp_cv_quals real_quals = memfn_quals; if (cxx_dialect < cxx14 && constexpr_p @@ -11865,9 +11864,7 @@ grokdeclarator (const cp_declarator *declarator, if (virtualp && identifier_p (unqualified_id) - && IDENTIFIER_OVL_OP_P (unqualified_id) - && (IDENTIFIER_OVL_OP_FLAGS (unqualified_id) - & OVL_OP_FLAG_ALLOC)) + && IDENTIFIER_NEWDEL_OP_P (unqualified_id)) { error ("%qD cannot be declared %<virtual%>, since it " "is always static", unqualified_id); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f807e8c..629b2dd 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5329,9 +5329,7 @@ push_template_decl_real (tree decl, bool is_friend) error ("destructor %qD declared as member template", decl); return error_mark_node; } - if (IDENTIFIER_OVL_OP_P (DECL_NAME (decl)) - && (IDENTIFIER_OVL_OP_FLAGS (DECL_NAME (decl)) - & OVL_OP_FLAG_ALLOC) + if (IDENTIFIER_NEWDEL_OP_P (DECL_NAME (decl)) && (!prototype_p (TREE_TYPE (decl)) || TYPE_ARG_TYPES (TREE_TYPE (decl)) == void_list_node || !TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl))) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index e2df355..9130c10 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -9073,9 +9073,7 @@ check_return_expr (tree retval, bool *no_warning) } /* Only operator new(...) throw(), can return NULL [expr.new/13]. */ - if (IDENTIFIER_OVL_OP_P (DECL_NAME (current_function_decl)) - && ((IDENTIFIER_OVL_OP_FLAGS (DECL_NAME (current_function_decl)) - & (OVL_OP_FLAG_ALLOC | OVL_OP_FLAG_DELETE)) == OVL_OP_FLAG_ALLOC) + if (IDENTIFIER_NEW_OP_P (DECL_NAME (current_function_decl)) && !TYPE_NOTHROW_P (TREE_TYPE (current_function_decl)) && ! flag_check_new && retval && null_ptr_cst_p (retval)) |