]> gcc.gnu.org Git - gcc.git/commitdiff
decl.c (cp_make_fname_decl): Set DECL_THIS_STATIC at toplevel.
authorJason Merrill <jason@redhat.com>
Thu, 10 Feb 2011 16:30:20 +0000 (11:30 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 10 Feb 2011 16:30:20 +0000 (11:30 -0500)
* 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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/regress/template-function1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/function1.C

index 20b0d4be65f1efbf02cceced2cdf6c807f923f82..c3f780abe0494e11994312330d4f25e0d9680f04 100644 (file)
@@ -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.
 
index 866069dd3e71b208e8764dbb45c258c4f4bd8f8b..663ca8f32aa8f65d05e4df664410807cdecbfadf 100644 (file)
@@ -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;
 }
index 7c06cc3d84fc6fc41ac62bec90eef2dbc39b39ca..58a59eecacf9b40edf5f74d503b3ed25fcfd1968 100644 (file)
@@ -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;
 }
index dc522e3e84618756dfb962f946b30302dc74a3f3..a43f34c87089b6a8632ed9ca8a8bd687e76ac820 100644 (file)
@@ -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 (file)
index 0000000..ec686ee
--- /dev/null
@@ -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;
index 1097c5bf9c2de1360e03c14cb3d7e5103a7038a0..3f82d5326f69adcddfd96c4c7b19fcd80bb081fc 100644 (file)
@@ -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;
This page took 0.133729 seconds and 5 git commands to generate.