// PR c++/24449 class Fooa { friend int main(); }; template class Foob { friend int main(); int i; }; int main() { Foob a; a.i = 7; } class Fooc { template friend int main(); // { dg-error "cannot declare .::main. to be a template" } }; template class Food { template friend int main(); // { dg-error "cannot declare .::main. to be a template" } }; template int main() {} // { dg-error "cannot declare .::main. to be a template" }