Commit d88511ae by Jason Merrill Committed by Jason Merrill

re PR c++/65879 (Bogus linkage errors for member class of anonymous class)

	PR c++/65879
	* decl.c (grokfndecl): Check the linkage of ctype, not just
	TYPE_ANONYMOUS_P.
	* tree.c (no_linkage_check): Skip the 'this' pointer.

From-SVN: r224844
parent 115ef7c5
2015-06-23 Jason Merrill <jason@redhat.com> 2015-06-23 Jason Merrill <jason@redhat.com>
PR c++/65879
* decl.c (grokfndecl): Check the linkage of ctype, not just
TYPE_ANONYMOUS_P.
* tree.c (no_linkage_check): Skip the 'this' pointer.
PR c++/66501 PR c++/66501
* class.c (type_has_nontrivial_assignment): New. * class.c (type_has_nontrivial_assignment): New.
* init.c (build_vec_init): Use it. * init.c (build_vec_init): Use it.
......
...@@ -7794,7 +7794,7 @@ grokfndecl (tree ctype, ...@@ -7794,7 +7794,7 @@ grokfndecl (tree ctype,
/* Members of anonymous types and local classes have no linkage; make /* Members of anonymous types and local classes have no linkage; make
them internal. If a typedef is made later, this will be changed. */ them internal. If a typedef is made later, this will be changed. */
if (ctype && (TYPE_ANONYMOUS_P (ctype) if (ctype && (!TREE_PUBLIC (TYPE_MAIN_DECL (ctype))
|| decl_function_context (TYPE_MAIN_DECL (ctype)))) || decl_function_context (TYPE_MAIN_DECL (ctype))))
publicp = 0; publicp = 0;
......
...@@ -2299,14 +2299,14 @@ no_linkage_check (tree t, bool relaxed_p) ...@@ -2299,14 +2299,14 @@ no_linkage_check (tree t, bool relaxed_p)
return no_linkage_check (TYPE_PTRMEM_CLASS_TYPE (t), relaxed_p); return no_linkage_check (TYPE_PTRMEM_CLASS_TYPE (t), relaxed_p);
case METHOD_TYPE: case METHOD_TYPE:
r = no_linkage_check (TYPE_METHOD_BASETYPE (t), relaxed_p);
if (r)
return r;
/* Fall through. */
case FUNCTION_TYPE: case FUNCTION_TYPE:
{ {
tree parm; tree parm = TYPE_ARG_TYPES (t);
for (parm = TYPE_ARG_TYPES (t); if (TREE_CODE (t) == METHOD_TYPE)
/* The 'this' pointer isn't interesting; a method has the same
linkage (or lack thereof) as its enclosing class. */
parm = TREE_CHAIN (parm);
for (;
parm && parm != void_list_node; parm && parm != void_list_node;
parm = TREE_CHAIN (parm)) parm = TREE_CHAIN (parm))
{ {
......
...@@ -23,9 +23,9 @@ namespace N2 { ...@@ -23,9 +23,9 @@ namespace N2 {
typedef struct { } B; typedef struct { } B;
struct C { struct C {
// { dg-final { scan-assembler-not ".weak\(_definition\)?\[ \t\]_?_ZN2N23._31C3fn1ENS0_1BE" { target c++11 } } } // { dg-final { scan-assembler-not ".weak\(_definition\)?\[ \t\]_?_ZN2N23._31C3fn1ENS0_1BE" { target c++11 } } }
static void fn1 (B) { } // { dg-error "no linkage" "" { target { ! c++11 } } } static void fn1 (B) { }
// { dg-final { scan-assembler-not ".weak\(_definition\)?\[ \t\]_?_ZN2N23._31C3fn2ES1_" { target c++11 } } } // { dg-final { scan-assembler-not ".weak\(_definition\)?\[ \t\]_?_ZN2N23._31C3fn2ES1_" { target c++11 } } }
static void fn2 (C) { } // { dg-error "no linkage" "" { target { ! c++11 } } } static void fn2 (C) { }
}; };
} const D; } const D;
......
// PR c++/65879
static struct
{
void f();
struct Inner
{
void g();
};
} x;
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