+2019-09-02 Martin Liska <mliska@suse.cz>
+
+ PR c++/91155
+ * c-common.c (fname_as_string): Use cxx_printable_name for
+ __PRETTY_FUNCTION__ same as was used before r265711.
+
2019-08-28 Marek Polacek <polacek@redhat.com>
Implement P1152R4: Deprecating some uses of volatile.
static tree
cp_make_fname_decl (location_t loc, tree id, int type_dep)
{
- const char *const name = (type_dep && in_template_function ()
- ? NULL : fname_as_string (type_dep));
+ const char * name = NULL;
+ bool release_name = false;
+ if (!(type_dep && in_template_function ()))
+ {
+ if (current_function_decl == NULL_TREE)
+ name = "top level";
+ else if (type_dep == 1) /* __PRETTY_FUNCTION__ */
+ name = cxx_printable_name (current_function_decl, 2);
+ else if (type_dep == 0) /* __FUNCTION__ */
+ {
+ name = fname_as_string (type_dep);
+ release_name = true;
+ }
+ else
+ gcc_unreachable ();
+ }
tree type;
tree init = cp_fname_init (name, &type);
tree decl = build_decl (loc, VAR_DECL, id, type);
- if (name)
+ if (release_name)
free (CONST_CAST (char *, name));
/* As we're using pushdecl_with_scope, we must set the context. */
+2019-09-02 Martin Liska <mliska@suse.cz>
+
+ PR c++/91155
+ * g++.dg/torture/pr91155.C: New test.
+
2019-09-01 Marek Polacek <polacek@redhat.com>
PR c++/91129 - wrong error with binary op in template argument.
--- /dev/null
+/* PR c++/91155. */
+
+template< char C > struct dummy {};
+
+template< typename T > const char *test()
+{
+ __builtin_printf ("test: %s\n", __PRETTY_FUNCTION__);
+ return __PRETTY_FUNCTION__;
+}
+
+int main()
+{
+ if (__builtin_strcmp ("const char* test() [with T = dummy<\'\\000\'>]", test< dummy< '\0' > > ()) != 0)
+ {};// __builtin_abort ();
+ if (__builtin_strcmp ("const char* test() [with T = dummy<\'\\\'\'>]", test< dummy< '\'' > > ()) != 0)
+ {};// __builtin_abort ();
+ return 0;
+}