aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-07-14 05:57:57 -0700
committerNathan Sidwell <nathan@acm.org>2020-07-14 06:27:07 -0700
commit31dbaab57fef485412a0369a222b9c252ad2713b (patch)
tree1cdd29a5079b04f3f34dabc3495732ba43312851 /gcc/cp/decl.c
parent6039cb96d1014373470a27f02e24c2c5e821a06c (diff)
downloadgcc-31dbaab57fef485412a0369a222b9c252ad2713b.zip
gcc-31dbaab57fef485412a0369a222b9c252ad2713b.tar.gz
gcc-31dbaab57fef485412a0369a222b9c252ad2713b.tar.bz2
c++: Comments & formatting
I found some bad formatting and misleading or incomplete comments during my spelunking around the c++FE. May as well clean up trunk and record what I noted. gcc/cp/ * cp-tree.h: Correct some tree lang flag comments, reformat some structure definitions. Note some structure sizes. Clarify some comments. (yyungetc): Delete. Not been a thing for some time. * class.c (copy_fndecl_with_name): Comment. (check_bases_and_members): Unnecessary {}. (layout_class_type): Comment. * cp-tree.def (UNBOUND_CLASS_TEMPLATE): Adjust comment. * decl.c: Fix some formatting & whitespace issues. (function_requirements_equivalent_p): Note why substitutions are needed. * decl2.c (no_linkage_error): Note that heroics about 'typedef struct { ... };' are no longer needed. * method.c: Whitespace. * name-lookup.c: Whitespace. (add_decl_to_level): Reformat a line. (print_binding_stack): Mark as DEBUG_FUNCTION. (has_using_namespace_std_directive_p): Delete comment. * pt.c: Whitespace * ptree.c: Whitespace. * rtti.c: Whitespace & comment. * tree.c: Comment. * typeck.c (structural_comptypes): Add comment.
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 60a09e9..5a26243 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -942,8 +942,11 @@ function_requirements_equivalent_p (tree newfn, tree oldfn)
tree reqs2 = get_trailing_function_requirements (oldfn);
if ((reqs1 != NULL_TREE) != (reqs2 != NULL_TREE))
return false;
+
+ /* Substitution is needed when friends are involved. */
reqs1 = maybe_substitute_reqs_for (reqs1, newfn);
reqs2 = maybe_substitute_reqs_for (reqs2, oldfn);
+
return cp_tree_equal (reqs1, reqs2);
}
@@ -2527,7 +2530,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
/* Merge parameter attributes. */
tree oldarg, newarg;
- for (oldarg = DECL_ARGUMENTS(olddecl), newarg = DECL_ARGUMENTS(newdecl);
+ for (oldarg = DECL_ARGUMENTS(olddecl), newarg = DECL_ARGUMENTS(newdecl);
oldarg && newarg;
oldarg = DECL_CHAIN(oldarg), newarg = DECL_CHAIN(newarg))
{
@@ -2737,6 +2740,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
TREE_USED (newdecl) = 1;
else if (TREE_USED (newdecl))
TREE_USED (olddecl) = 1;
+
if (VAR_P (newdecl))
{
if (DECL_READ_P (olddecl))
@@ -2744,6 +2748,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
else if (DECL_READ_P (newdecl))
DECL_READ_P (olddecl) = 1;
}
+
if (DECL_PRESERVE_P (olddecl))
DECL_PRESERVE_P (newdecl) = 1;
else if (DECL_PRESERVE_P (newdecl))
@@ -4683,9 +4688,9 @@ cp_make_fname_decl (location_t loc, tree id, int type_dep)
return decl;
}
-/* Install DECL as a builtin function at current (global) scope.
- Return the new decl (if we found an existing version). Also
- installs it into ::std, if it's not '_*'. */
+/* Install DECL as a builtin function at current global scope. Return
+ the new decl (if we found an existing version). Also installs it
+ into ::std, if it's not '_*'. */
tree
cxx_builtin_function (tree decl)
@@ -13423,6 +13428,7 @@ grokdeclarator (const cp_declarator *declarator,
in-class defaulted functions, but that breaks grokfndecl.
So set it here. */
funcdef_flag = true;
+
if (template_class_depth (current_class_type) == 0)
{
decl = check_explicit_specialization