From d31e45926b8a7ca2c1ab00c37c71bf5adf509cee Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 10 Feb 2011 16:30:20 +0000 Subject: [PATCH] * decl.c (cp_make_fname_decl): Set DECL_THIS_STATIC at toplevel. * semantics.c (finish_fname): Only return the name if we're in a function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170009 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl.c | 5 +++- gcc/cp/semantics.c | 2 +- gcc/testsuite/ChangeLog | 3 +++ .../g++.dg/cpp0x/regress/template-function1.C | 28 ++++++++++++++++++++++ gcc/testsuite/g++.dg/template/function1.C | 8 +++---- 6 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/regress/template-function1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 20b0d4b..c3f780a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-02-09 Jason Merrill + * decl.c (cp_make_fname_decl): Set DECL_THIS_STATIC at toplevel. + * semantics.c (finish_fname): Only return the name if we're in + a function. + * decl.c (build_enumerator): Don't perform integral promotions on non-integral constants. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 866069d..663ca8f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3706,7 +3706,10 @@ cp_make_fname_decl (location_t loc, tree id, int type_dep) LOOKUP_ONLYCONVERTING); } else - pushdecl_top_level_and_finish (decl, init); + { + DECL_THIS_STATIC (decl) = true; + pushdecl_top_level_and_finish (decl, init); + } return decl; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 7c06cc3..58a59ee 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2324,7 +2324,7 @@ finish_fname (tree id) tree decl; decl = fname_decl (input_location, C_RID_CODE (id), id); - if (processing_template_decl) + if (processing_template_decl && current_function_decl) decl = DECL_NAME (decl); return decl; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dc522e3..a43f34c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-02-09 Jason Merrill + * g++.dg/template/function1.C: Adjust for C++0x mode. + * g++.dg/cpp0x/regress/template-function1.C: Copy it. + * g++.dg/ext/label10.C: Adjust for C++0x mode. * g++.dg/cpp0x/regress/ext-label10.C: Copy it. diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/template-function1.C b/gcc/testsuite/g++.dg/cpp0x/regress/template-function1.C new file mode 100644 index 0000000..ec686ee --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/template-function1.C @@ -0,0 +1,28 @@ +// PR c++/38647 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template struct A {}; +const char func[] = "abc"; +template struct A {}; // { dg-error "cannot appear|is invalid|not a valid" } + +char a1[1]; +A a; + +template struct B {}; +template struct B<__FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid" } + +char b1[1]; +B b; + +template struct C {}; +template struct C<__PRETTY_FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid" } + +char c1[1]; +C c; + +template struct D {}; +template struct D<__func__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid|function scope" } + +char d1[1]; +D d; diff --git a/gcc/testsuite/g++.dg/template/function1.C b/gcc/testsuite/g++.dg/template/function1.C index 1097c5b..3f82d53 100644 --- a/gcc/testsuite/g++.dg/template/function1.C +++ b/gcc/testsuite/g++.dg/template/function1.C @@ -3,25 +3,25 @@ template struct A {}; const char func[] = "abc"; -template struct A {}; // { dg-error "cannot appear|is invalid" } +template struct A {}; // { dg-error "cannot appear|is invalid|not a valid" } char a1[1]; A a; template struct B {}; -template struct B<__FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid" } +template struct B<__FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid" } char b1[1]; B b; template struct C {}; -template struct C<__PRETTY_FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid" } +template struct C<__PRETTY_FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid" } char c1[1]; C c; template struct D {}; -template struct D<__func__, N> {}; // { dg-error "cannot appear|is invalid" } +template struct D<__func__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid|function scope" } char d1[1]; D d; -- 2.7.4