diff options
author | Jason Merrill <jason@redhat.com> | 2011-02-10 11:30:20 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-02-10 11:30:20 -0500 |
commit | be771f25275b5d4d1c7033d4d66f1412733f7046 (patch) | |
tree | 0d506bb1580f9a18d55f23dc2e50ed7ef40b9abc /gcc | |
parent | c51dc544b1c7f64888f9c3023700a5793e427aba (diff) | |
download | gcc-be771f25275b5d4d1c7033d4d66f1412733f7046.zip gcc-be771f25275b5d4d1c7033d4d66f1412733f7046.tar.gz gcc-be771f25275b5d4d1c7033d4d66f1412733f7046.tar.bz2 |
decl.c (cp_make_fname_decl): Set DECL_THIS_STATIC at toplevel.
* 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.
From-SVN: r170009
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 5 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/regress/template-function1.C | 28 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/function1.C | 8 |
6 files changed, 44 insertions, 6 deletions
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 <jason@redhat.com> + * 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 <jason@redhat.com> + * 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<const char *, int> struct A {}; +const char func[] = "abc"; +template<int N> struct A<func, N> {}; // { dg-error "cannot appear|is invalid|not a valid" } + +char a1[1]; +A<a1, 0> a; + +template<const char *, int> struct B {}; +template<int N> struct B<__FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid" } + +char b1[1]; +B<b1, 0> b; + +template<const char *, int> struct C {}; +template<int N> struct C<__PRETTY_FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid" } + +char c1[1]; +C<c1, 0> c; + +template<const char *, int> struct D {}; +template<int N> struct D<__func__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid|function scope" } + +char d1[1]; +D<d1, 0> 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<const char *, int> struct A {}; const char func[] = "abc"; -template<int N> struct A<func, N> {}; // { dg-error "cannot appear|is invalid" } +template<int N> struct A<func, N> {}; // { dg-error "cannot appear|is invalid|not a valid" } char a1[1]; A<a1, 0> a; template<const char *, int> struct B {}; -template<int N> struct B<__FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid" } +template<int N> struct B<__FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid" } char b1[1]; B<b1, 0> b; template<const char *, int> struct C {}; -template<int N> struct C<__PRETTY_FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid" } +template<int N> struct C<__PRETTY_FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid" } char c1[1]; C<c1, 0> c; template<const char *, int> struct D {}; -template<int N> struct D<__func__, N> {}; // { dg-error "cannot appear|is invalid" } +template<int N> struct D<__func__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid|function scope" } char d1[1]; D<d1, 0> d; |