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.
LOOKUP_ONLYCONVERTING);
}
else
- pushdecl_top_level_and_finish (decl, init);
+ {
+ DECL_THIS_STATIC (decl) = true;
+ pushdecl_top_level_and_finish (decl, init);
+ }
return decl;
}
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;
}
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.
--- /dev/null
+// 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;
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;