aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2012-02-14 03:39:51 -0500
committerJason Merrill <jason@gcc.gnu.org>2012-02-14 03:39:51 -0500
commitf0ebe02d7fb107fa61c9f04b2dad2c63886b8c3d (patch)
tree9ca4bca98238648f7e0572eaf4f22cb388381a15 /gcc/cp
parentd4a698d494b9bc5344b49824ac3aa27710833fa8 (diff)
downloadgcc-f0ebe02d7fb107fa61c9f04b2dad2c63886b8c3d.zip
gcc-f0ebe02d7fb107fa61c9f04b2dad2c63886b8c3d.tar.gz
gcc-f0ebe02d7fb107fa61c9f04b2dad2c63886b8c3d.tar.bz2
re PR c++/39055 ([DR 1443][4.4/4.5/4.6/4.7 regression] questionable default parameter of a member function accepted)
PR c++/39055 * decl.c (local_variable_p_walkfn): Don't check DECL_ARTIFICIAL. From-SVN: r184199
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c10
2 files changed, 12 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6680668..c20077c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2012-02-14 Jason Merrill <jason@redhat.com>
+
+ PR c++/39055
+ * decl.c (local_variable_p_walkfn): Don't check DECL_ARTIFICIAL.
+
2012-02-14 Jakub Jelinek <jakub@redhat.com>
PR c/52181
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8fcfbd5..f0ba181 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10509,7 +10509,9 @@ static tree
local_variable_p_walkfn (tree *tp, int *walk_subtrees,
void *data ATTRIBUTE_UNUSED)
{
- if (local_variable_p (*tp) && !DECL_ARTIFICIAL (*tp))
+ /* Check DECL_NAME to avoid including temporaries. We don't check
+ DECL_ARTIFICIAL because we do want to complain about 'this'. */
+ if (local_variable_p (*tp) && DECL_NAME (*tp))
return *tp;
else if (TYPE_P (*tp))
*walk_subtrees = 0;
@@ -10517,7 +10519,6 @@ local_variable_p_walkfn (tree *tp, int *walk_subtrees,
return NULL_TREE;
}
-
/* Check that ARG, which is a default-argument expression for a
parameter DECL, is valid. Returns ARG, or ERROR_MARK_NODE, if
something goes wrong. DECL may also be a _TYPE node, rather than a
@@ -10578,7 +10579,10 @@ check_default_argument (tree decl, tree arg)
var = cp_walk_tree_without_duplicates (&arg, local_variable_p_walkfn, NULL);
if (var)
{
- error ("default argument %qE uses local variable %qD", arg, var);
+ if (DECL_NAME (var) == this_identifier)
+ permerror (input_location, "default argument %qE uses %qD", arg, var);
+ else
+ error ("default argument %qE uses local variable %qD", arg, var);
return error_mark_node;
}