typedefstruct{// expected-error {{anonymous non-C-compatible type given name for linkage purposes by typedef declaration after its linkage was computed; add a tag name here to establish linkage prior to definition}}
}Lambda2;// expected-note {{type is given name 'Lambda2' for linkage purposes by this typedef declaration}}
typedefstruct{// expected-warning {{anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here}}
enumE{
a=[]{return1;}()// expected-note {{type is not C-compatible due to this lambda expression}}
};
}Lambda3;// expected-note {{type is given name 'Lambda3' for linkage purposes by this typedef declaration}}
#endif
typedefstruct{// expected-warning {{anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here}}
template<int>voidf(){}// expected-note {{type is not C-compatible due to this member declaration}}
}Template;// expected-note {{type is given name 'Template' for linkage purposes by this typedef declaration}}
typedefstruct{// expected-warning {{anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here}}
structU{
voidf();// expected-note {{type is not C-compatible due to this member declaration}}
};
}Nested;// expected-note {{type is given name 'Nested' for linkage purposes by this typedef declaration}}
typedefstruct{// expected-warning {{anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here}}
friendvoidf(){}// expected-note {{type is not C-compatible due to this friend declaration}}
}Friend;// expected-note {{type is given name 'Friend' for linkage purposes by this typedef declaration}}
typedefstruct{// expected-warning {{anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here}}
template<typenameT>friendvoidf(){}// expected-note {{type is not C-compatible due to this friend declaration}}
}FriendTemplate;// expected-note {{type is given name 'FriendTemplate' for linkage purposes by this typedef declaration}}
// Check that we don't diagnose the permitted cases:
typedefstruct{
// (non-members)
_Static_assert(true,"");
int:0;
/*empty-declaration*/;
// non-static data members
inta;
// member enumerations
enumE{x,y,z};
// member classes
structS{};
// recursively
structT{inta;};
}OK;
// There are still some known permitted cases that require an early linkage
// computation. Ensure we diagnose those too.
namespaceValidButUnsupported{
#if __cplusplus >= 201402L
template<typenameT>autocompute_linkage(){
staticintn;
return&n;
}
typedefstruct{// expected-error {{unsupported: anonymous type given name for linkage purposes by typedef declaration after its linkage was computed; add a tag name here to establish linkage}}
structX{};
decltype(compute_linkage<X>())a;
}A;// expected-note {{by this typedef declaration}}
#endif
// This fails in some language modes but not others.