re PR c++/24449 (Unable to declare friend main() from class template)
/cp 2012-10-12 Paolo Carlini <paolo.carlini@oracle.com> PR c++/24449 * decl.c (grokfndecl): When checking for ::main declarations use PROCESSING_REAL_TEMPLATE_DECL_P(). /testsuite 2012-10-12 Paolo Carlini <paolo.carlini@oracle.com> PR c++/24449 * g++.dg/parse/friend-main.C: New. From-SVN: r192402
This commit is contained in:
parent
5e54f81df1
commit
e74a506f4e
|
@ -1,3 +1,9 @@
|
|||
2012-10-12 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/24449
|
||||
* decl.c (grokfndecl): When checking for ::main declarations
|
||||
use PROCESSING_REAL_TEMPLATE_DECL_P().
|
||||
|
||||
2012-10-12 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
PR c++/53055
|
||||
|
|
|
@ -7416,7 +7416,7 @@ grokfndecl (tree ctype,
|
|||
|
||||
if (ctype == NULL_TREE && DECL_MAIN_P (decl))
|
||||
{
|
||||
if (processing_template_decl)
|
||||
if (PROCESSING_REAL_TEMPLATE_DECL_P())
|
||||
error ("cannot declare %<::main%> to be a template");
|
||||
if (inlinep)
|
||||
error ("cannot declare %<::main%> to be inline");
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2012-10-12 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/24449
|
||||
* g++.dg/parse/friend-main.C: New.
|
||||
|
||||
2012-10-12 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
PR c++/53055
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// PR c++/24449
|
||||
|
||||
class Fooa
|
||||
{
|
||||
friend int main();
|
||||
};
|
||||
|
||||
template <class T> class Foob
|
||||
{
|
||||
friend int main();
|
||||
int i;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Foob<void> a;
|
||||
a.i = 7;
|
||||
}
|
||||
|
||||
class Fooc
|
||||
{
|
||||
template<class T> friend int main(); // { dg-error "cannot declare .::main. to be a template" }
|
||||
};
|
||||
|
||||
template<class T> class Food
|
||||
{
|
||||
template<class U> friend int main(); // { dg-error "cannot declare .::main. to be a template" }
|
||||
};
|
||||
|
||||
template<class U> int main() {} // { dg-error "cannot declare .::main. to be a template" }
|
Loading…
Reference in New Issue