Commit 977bc3ee by Alexandre Oliva Committed by Alexandre Oliva

[PR c++/84973] don't defer output of uninstantiated templates

When an anon struct gets a name through a typedef, we reset its
linkage and that of its members.  Member functions may get vague
linkage, which schedules them for deferred output, but we don't want
to add them to the queue if they're uninstantiated templates,
e.g. because the enclosing function is a template.  They will be added
as needed when the enclosing template is instantiated.


for  gcc/cp/ChangeLog

	PR c++/84973
	* decl2.c (note_vague_linkage_fn): Don't defer uninstantiated
	templates.

for  gcc/testsuite/ChangeLog

	PR c++/84973
	* g++.dg/template/pr84973.C: New.
	* g++.dg/template/pr84973-2.C: New.
	* g++.dg/template/pr84973-3.C: New.

From-SVN: r258914
parent 04acc378
2018-03-28 Alexandre Oliva <aoliva@redhat.com>
PR c++/84973
* decl2.c (note_vague_linkage_fn): Don't defer uninstantiated
templates.
PR c++/84968
* tree.c (strip_typedefs_expr): Reject STATEMENT_LISTs.
......
......@@ -739,6 +739,9 @@ check_classfn (tree ctype, tree function, tree template_parms)
void
note_vague_linkage_fn (tree decl)
{
if (processing_template_decl)
return;
DECL_DEFER_OUTPUT (decl) = 1;
vec_safe_push (deferred_fns, decl);
}
......
2018-03-28 Alexandre Oliva <aoliva@redhat.com>
PR c++/84973
* g++.dg/template/pr84973.C: New.
* g++.dg/template/pr84973-2.C: New.
* g++.dg/template/pr84973-3.C: New.
PR c++/84968
* g++.dg/eh/pr84968.C: New.
......
// { dg-do compile }
template <int> void a() {
typedef struct {
void b() try { b; } catch (short) { // { dg-error "invalid use" }
}
} c;
}
int
main() {
a<0>();
}
// { dg-do link }
template <int> void a() {
typedef struct {
void b() try { b(); } catch (short) {
}
} c;
}
int
main() {
a<0>();
}
// { dg-do compile }
template <int> void a() {
typedef struct {
void b() try { b; } catch (short) {
}
} c;
}
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