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.
Details
Details
- Reviewers
- None
Diff Detail
Diff Detail
Event Timeline
Comment Actions
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. |
This looks wrong in C. Given:
... the enum definition should not be visible outside the function.