aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2012-10-12 14:38:11 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2012-10-12 14:38:11 +0000
commite74a506f4eec90fc1d4839f8cde506be8f99c9de (patch)
treee7b34a56f7034d83f32c0d141c6cd696622fecc9
parent5e54f81df1b2336a3ddc4f77180f4e579436b663 (diff)
downloadgcc-e74a506f4eec90fc1d4839f8cde506be8f99c9de.zip
gcc-e74a506f4eec90fc1d4839f8cde506be8f99c9de.tar.gz
gcc-e74a506f4eec90fc1d4839f8cde506be8f99c9de.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/friend-main.C30
4 files changed, 42 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ad76541..6730b10 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index f97f7b1..468343f 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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");
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3b9f121..862b427 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/parse/friend-main.C b/gcc/testsuite/g++.dg/parse/friend-main.C
new file mode 100644
index 0000000..e6d32e7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/friend-main.C
@@ -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" }