1 2002-05-24 Jakub Jelinek <jakub@redhat.com>
4 * decl.c (cp_make_fname_decl): If outside of function, emit
5 the variable immediately.
6 * call.c (build_call): Avoid crashing when noreturn function
7 is called outside of function context.
9 * g++.dg/ext/pretty1.C: New test.
10 * g++.dg/ext/pretty2.C: New test.
12 --- gcc/cp/decl.c.jj Tue May 21 20:27:10 2002
13 +++ gcc/cp/decl.c Fri May 24 17:28:16 2002
14 @@ -6772,7 +6772,10 @@ cp_make_fname_decl (id, type_dep)
17 cp_finish_decl (decl, init, NULL_TREE, LOOKUP_ONLYCONVERTING);
20 + if (!current_function_decl)
21 + rest_of_decl_compilation (decl, 0, 1, 0);
26 --- gcc/cp/call.c.jj Mon Apr 15 14:48:51 2002
27 +++ gcc/cp/call.c Fri May 24 12:49:22 2002
28 @@ -408,7 +408,7 @@ build_call (function, parms)
29 nothrow = ((decl && TREE_NOTHROW (decl))
30 || TYPE_NOTHROW_P (TREE_TYPE (TREE_TYPE (function))));
32 - if (decl && TREE_THIS_VOLATILE (decl))
33 + if (decl && TREE_THIS_VOLATILE (decl) && current_function_decl)
34 current_function_returns_abnormally = 1;
36 if (decl && TREE_DEPRECATED (decl))
37 --- gcc/testsuite/g++.dg/ext/pretty1.C.jj Fri May 24 18:09:27 2002
38 +++ gcc/testsuite/g++.dg/ext/pretty1.C Fri May 24 18:13:10 2002
41 +// Test whether __PRETTY_FUNCTION__ works in templates, functions and
42 +// in initializers at global scope
46 +extern "C" void __assert_fail (const char *, const char *,
47 + unsigned int, const char *)
48 + throw() __attribute__((noreturn));
49 +extern "C" void abort (void);
50 +extern "C" void exit (int);
52 +#define str(expr) #expr
53 +#define assert(expr) \
54 + ((expr) ? 0 : (__assert_fail (str(expr), __FILE__, __LINE__, \
55 + __PRETTY_FUNCTION__), 0))
57 +int __attribute__((noinline))
63 +template<class T> int
66 + return (assert (foo ()), 1);
72 + return (assert (foo ()), 2);
75 +int a = (assert (foo ()), 1);
76 +int b = (assert (foo ()), 2);
82 + unsigned char *d = 0;
83 + int e = (assert (foo ()), 3);
92 + int f = (assert (foo ()), 4);
95 +void __attribute__((noinline))
96 +__assert_fail (const char *cond, const char *file, unsigned int line,
97 + const char *pretty) throw ()
102 +// { dg-final { scan-assembler "int bar\\(T\\).*with T = int" } }
103 +// { dg-final { scan-assembler "top level" } }
104 +// { dg-final { scan-assembler "int main\\(\\)" } }
105 +// { dg-final { scan-assembler "int bar\\(T\\).*with T = double" } }
106 +// { dg-final { scan-assembler "int bar\\(T\\).*with T = unsigned char\*" } }
107 --- gcc/testsuite/g++.dg/ext/pretty2.C.jj Fri May 24 18:09:27 2002
108 +++ gcc/testsuite/g++.dg/ext/pretty2.C Fri May 24 18:13:42 2002
111 +// Test whether __PRETTY_FUNCTION__ works in templates, functions and
112 +// in initializers at global scope
114 +// { dg-options "" }
116 +extern "C" void __assert_fail (const char *, const char *,
117 + unsigned int, const char *)
118 + throw() __attribute__((noreturn));
119 +extern "C" void abort (void);
120 +extern "C" void exit (int);
122 +#define str(expr) #expr
123 +#define assert(expr) \
124 + ((expr) ? 0 : (__assert_fail (str(expr), __FILE__, __LINE__, \
125 + __PRETTY_FUNCTION__), 0))
127 +int __attribute__((noinline))
133 +template<class T> int
136 + return (assert (foo ()), 1);
142 + return (assert (foo ()), 2);
145 +int a = (assert (foo ()), 1);
146 +int b = (assert (foo ()), 2);
152 + unsigned char *d = 0;
153 + int e = (assert (foo ()), 3);
162 + int f = (assert (foo ()), 4);
165 +void __attribute__((noinline))
166 +__assert_fail (const char *cond, const char *file, unsigned int line,
167 + const char *pretty) throw ()