NULL-named TYPE_DECL node helps dwarfout.c to know when it needs
to output a representation of a tagged type, and it also gives
us a convenient place to record the "scope start" address for the
- tagged type. */
+ tagged type, and it is used to track whether the type is used
+ in a non-local context via mark_decl_used. */
TYPE_STUB_DECL (type) = pushdecl (build_decl (loc,
TYPE_DECL, NULL_TREE, type));
specs->typedef_p = true;
specs->locations[cdw_typedef] = loc;
}
+
+ if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
+ || TREE_CODE (type) == ENUMERAL_TYPE)
+ mark_decl_used (TYPE_STUB_DECL (type), false);
+
if (spec.expr)
{
tree expr = save_expr (fold_convert (void_type_node, spec.expr));
tree exp2 = build_unary_op (loc, ADDR_EXPR, exp, false);
- /* If the function is defined and known to not to require a non-local
+ /* If the function is defined and known to not require a non-local
context, make sure no trampoline is generated. */
if (TREE_CODE (exp) == FUNCTION_DECL
&& DECL_INITIAL (exp) && !C_FUNC_NONLOCAL_CONTEXT (exp))
--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-effective-target trampolines } */
+/* { dg-options "" } */
+
+
+void *a0() {
+ int b = 1;
+ struct bar { char c[b]; };
+ struct bar e() { struct bar f; return f; }
+ return &e; /* { dg-warning "referencing local context" } */
+}
+
+void *a1() {
+ int b = 1;
+ struct bar { char c[b]; };
+ struct bar e() { }
+ return &e;
+}
+
+void *a2() {
+ int b = 1;
+ struct bar { char c[b]; };
+ struct bar e() { typeof(struct bar) f; return f; }
+ return &e; /* { dg-warning "referencing local context" } */
+}
+
+void *a3() {
+ int b = 1;
+ struct bar { char c[b]; };
+ struct bar (*d)();
+ struct bar e() { typeof((*d)()) f; return f; }
+ return &e; /* { dg-warning "referencing local context" } */
+}
+
+void *a4() {
+ int b = 1;
+ struct bar { char c[b]; };
+ struct bar e() { struct bar f; return f; }
+ return &e; /* { dg-warning "referencing local context" } */
+}
+
+
--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-effective-target trampolines } */
+/* { dg-options "-O1 -fno-tree-dse" } */
+
+void a() {
+ int b = 0;
+ struct bar { char c[b]; };
+ struct bar (*d)();
+ struct bar e() { struct bar f; return f; }
+ d = e;
+ d();
+}
+