Commit 8f9336a4 authored by Jeff Chapman's avatar Jeff Chapman

c++: Fix push_namespace segfault with modules

push_namespace was reusing an earlier find_namespace_slot result after
it was invalidated by pushdecl in corner cases.

2020-05-15  Jeff Chapman II  <[email protected]>

gcc/cp/
	* name-lookup.c (push_namespace): Fix slot invalidation related
	segfault when compiling with modules enabled.
parent 7c60897d
2020-05-15 Jeff Chapman II <[email protected]>
* name-lookup.c (push_namespace): Fix slot invalidation related
segfault when compiling with modules enabled.
2020-05-12 Marek Polacek <[email protected]>
PR c++/95074
......
......@@ -8819,6 +8819,8 @@ push_namespace (tree name, bool make_inline)
{
/* finish up making the namespace. */
add_decl_to_level (NAMESPACE_LEVEL (current_namespace), ns);
/* pushdecl may invalidate slot, find name again. */
slot = find_namespace_slot (current_namespace, name, true);
make_namespace_finish (ns, slot);
/* Add the anon using-directive here, we don't do it in
......
// { dg-additional-options "-fmodules-ts" }
module;
#include <cstdio>
#include <string_view>
export module foo;
// { dg-additional-options "-fmodules-ts" }
// reduced from string-view1 through cvise. Broken under c++2a too.
namespace std {
typedef int a;
int b;
decltype(nullptr) c;
namespace xyz {}
__builtin_va_list d;
int n;
int e;
int f;
int g;
int h;
int i;
int j;
int k;
typedef struct l m;
typedef struct aa w;
typedef struct x o;
typedef x p;
long q;
long r;
typedef l s;
extern p ab;
void t();
void v();
extern p ac;
void ad();
int ae;
int af;
extern p ag;
extern p ah;
void ai();
void y();
int aj;
int ak;
int al;
char am;
int an;
a ao;
int ap;
int aq;
void z();
int ar;
int as;
void at();
void au();
void av();
void aw();
int u;
namespace zz {
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment