From 23413aedf6423fb5debde561b80294c9421c0e88 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 14 Mar 2013 13:09:11 +0000 Subject: [PATCH] PR c++/56614 * decl.c (local_variable_p_walkfn): Check DECL_ARTIFICIAL again. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196658 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/decl.c | 5 ++-- gcc/testsuite/g++.dg/cpp0x/initlist-defarg1.C | 36 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-defarg1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ccdb401d928..77f3f824c0a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2013-03-14 Jason Merrill + PR c++/56614 + * decl.c (local_variable_p_walkfn): Check DECL_ARTIFICIAL again. + PR c++/56346 * decl.c (register_dtor_fn): Pass null to __cxa_thread_atexit dso_handle parm on targets without __cxa_atexit. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 92114fff6c7..0e668408119 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10803,9 +10803,8 @@ static tree local_variable_p_walkfn (tree *tp, int *walk_subtrees, void * /*data*/) { - /* 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)) + if (local_variable_p (*tp) + && (!DECL_ARTIFICIAL (*tp) || DECL_NAME (*tp) == this_identifier)) return *tp; else if (TYPE_P (*tp)) *walk_subtrees = 0; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-defarg1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-defarg1.C new file mode 100644 index 00000000000..45eb2d5e1f0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-defarg1.C @@ -0,0 +1,36 @@ +// PR c++/56614 +// { dg-require-effective-target c++11 } + +#include + +namespace std +{ + template + struct allocator + { }; + + template > + struct vector + { + vector(std::initializer_list, const Alloc& = Alloc()) { } + }; +} + +void func() { } + +enum E { ee }; + +struct C +{ + template + C(T, std::vector = std::vector({ ee })) + { } +}; + +struct G +{ + void gen() + { + C c(&func); + } +}; -- 2.11.4.GIT