/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
+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
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");
+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
--- /dev/null
+// 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" }