This is an archive of the discontinued LLVM Phabricator instance.

Put types defined in prototype into translation unit context
AbandonedPublic

Authored by sepavloff on May 27 2014, 10:53 AM.

Details

Reviewers
None
Summary

If a type is defined in a function prototype, put it into translation unit
rather than current context. This patch fixes PR19018, in which such type
was placed into class context, but as it did not have access specifier,
assertion violation occurred.

Diff Detail

Event Timeline

sepavloff updated this revision to Diff 9841.May 27 2014, 10:53 AM
sepavloff retitled this revision from to Put types defined in prototype into translation unit context.
sepavloff updated this object.
sepavloff edited the test plan for this revision. (Show Details)
sepavloff added a subscriber: Unknown Object (MLST).
rsmith added a subscriber: rsmith.May 29 2014, 8:15 PM

I think this is the wrong place for this fix; can we check for types being defined in a parameter type sooner, and mark the type invalid in that case? (The assertion will be suppressed for an invalid type.)

We also assert on this test case, for a reason that looks closely related:

struct pr19018 {
  short foo6 (struct bar0 {} bar3); // expected-error{{cannot be defined in a parameter type}}
  bar0 *p;
};

... and I'd really like us to fix this more thoroughly, for all relevant cases.

lib/Sema/SemaDecl.cpp
10743–10748

This looks wrong in C. Given:

void f(enum E { e } *p);

... the enum definition should not be visible outside the function.

sepavloff removed subscribers: rsmith, Unknown Object (MLST).Jun 14 2014, 9:39 AM
sepavloff abandoned this revision.Jun 14 2014, 9:41 AM

This revision is superceder by D4145.