Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 08f7f62ad8debca71f444a3272b26be1 > files > 31

gcc3.3-3.3.6-16.mga7.src.rpm

2002-05-24  Jakub Jelinek  <jakub@redhat.com>

	PR c++/6794
	* decl.c (cp_make_fname_decl): If outside of function, emit
	the variable immediately.

	* g++.dg/ext/pretty1.C: New test.
	* g++.dg/ext/pretty2.C: New test.

--- gcc-3.3.1/gcc/cp/decl.c.pr6794	2003-07-07 07:20:20.000000000 +0200
+++ gcc-3.3.1/gcc/cp/decl.c	2003-07-16 16:50:02.000000000 +0200
@@ -7147,6 +7147,9 @@ cp_make_fname_decl (id, type_dep)
 
   cp_finish_decl (decl, init, NULL_TREE, LOOKUP_ONLYCONVERTING);
       
+  if (!current_function_decl)
+    rest_of_decl_compilation (decl, 0, 1, 0);
+
   return decl;
 }
 
--- gcc-3.3.1/gcc/testsuite/g++.dg/ext/pretty1.C.pr6794	2003-07-16 16:50:02.000000000 +0200
+++ gcc-3.3.1/gcc/testsuite/g++.dg/ext/pretty1.C	2003-07-16 16:56:16.000000000 +0200
@@ -0,0 +1,67 @@
+// PR c++/6794
+// Test whether __PRETTY_FUNCTION__ works in templates, functions and
+// in initializers at global scope
+// { dg-do compile }
+// { dg-options "" }
+
+extern "C" void __assert_fail (const char *, const char *,
+			       unsigned int, const char *)
+  throw() __attribute__((noreturn));
+extern "C" void abort (void);
+extern "C" void exit (int);
+
+#define str(expr) #expr
+#define assert(expr)						\
+  ((expr) ? 0 : (__assert_fail (str(expr), __FILE__, __LINE__,	\
+				__PRETTY_FUNCTION__), 0))
+
+int __attribute__((noinline))
+foo (void)
+{
+  return 1;
+}
+
+template<class T> int
+bar (T)
+{
+  return (assert (foo ()), 1);
+}
+
+template<> int
+bar<int> (int)
+{
+  return (assert (foo ()), 2);
+}
+
+int a = (assert (foo ()), 1);
+int b = (assert (foo ()), 2);
+
+int
+main ()
+{
+  double c = 1.0;
+  unsigned char *d = 0;
+  int e = (assert (foo ()), 3);
+
+  bar (c);
+  bar (d);
+  bar (e);
+}
+
+namespace N
+{
+  int f = (assert (foo ()), 4);
+}
+
+void __attribute__((noinline))
+__assert_fail (const char *cond, const char *file, unsigned int line,
+	       const char *pretty) throw ()
+{
+  abort ();
+}
+
+// { dg-final { scan-assembler "int bar\\(T\\).*with T = int" } }
+// { dg-final { scan-assembler "top level" } }
+// { dg-final { scan-assembler "int main\\(\\)" } }
+// { dg-final { scan-assembler "int bar\\(T\\).*with T = double" } }
+// { dg-final { scan-assembler "int bar\\(T\\).*with T = unsigned char\*" } }
--- gcc-3.3.1/gcc/testsuite/g++.dg/ext/pretty2.C.pr6794	2003-07-16 16:50:02.000000000 +0200
+++ gcc-3.3.1/gcc/testsuite/g++.dg/ext/pretty2.C	2003-07-16 16:50:02.000000000 +0200
@@ -0,0 +1,61 @@
+// PR c++/6794
+// Test whether __PRETTY_FUNCTION__ works in templates, functions and
+// in initializers at global scope
+// { dg-do run }
+// { dg-options "" }
+
+extern "C" void __assert_fail (const char *, const char *,
+			       unsigned int, const char *)
+  throw() __attribute__((noreturn));
+extern "C" void abort (void);
+extern "C" void exit (int);
+
+#define str(expr) #expr
+#define assert(expr)						\
+  ((expr) ? 0 : (__assert_fail (str(expr), __FILE__, __LINE__,	\
+				__PRETTY_FUNCTION__), 0))
+
+int __attribute__((noinline))
+foo (void)
+{
+  return 1;
+}
+
+template<class T> int
+bar (T)
+{
+  return (assert (foo ()), 1);
+}
+
+template<> int
+bar<int> (int)
+{
+  return (assert (foo ()), 2);
+}
+
+int a = (assert (foo ()), 1);
+int b = (assert (foo ()), 2);
+
+int
+main ()
+{
+  double c = 1.0;
+  unsigned char *d = 0;
+  int e = (assert (foo ()), 3);
+
+  bar (c);
+  bar (d);
+  bar (e);
+}
+
+namespace N
+{
+  int f = (assert (foo ()), 4);
+}
+
+void __attribute__((noinline))
+__assert_fail (const char *cond, const char *file, unsigned int line,
+	       const char *pretty) throw ()
+{
+  abort ();
+}