* [C++ Patch] Handle separately <inline> and <constexpr> in grokfndecl error messages
@ 2013-03-25 23:40 Paolo Carlini
2013-03-26 3:09 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2013-03-25 23:40 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 253 bytes --]
Hi,
I split out two - rather straightforward IMHO - changes from the largish
patch I posted a few days ago: this one improves the accuracy of some
error messages produced by grokfndecl.
Tested x86_64-linux.
Thanks,
Paolo.
//////////////////////
[-- Attachment #2: CL_grokfndecl_1 --]
[-- Type: text/plain, Size: 297 bytes --]
/cp
2013-03-25 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (grokfndecl): Handle separately <inline> and <constexpr>
error messages.
/testsuite
2013-03-25 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp0x/constexpr-friend-2.C: New.
* g++.dg/cpp0x/constexpr-main.C: Likewise.
[-- Attachment #3: patch_grokfndecl_1 --]
[-- Type: text/plain, Size: 1943 bytes --]
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 197053)
+++ cp/decl.c (working copy)
@@ -7426,13 +7426,16 @@ grokfndecl (tree ctype,
return NULL_TREE;
}
+ if (inlinep & 1)
+ error ("%<inline%> is not allowed in declaration of friend "
+ "template specialization %qD",
+ decl);
+ if (inlinep & 2)
+ error ("%<constexpr%> is not allowed in declaration of friend "
+ "template specialization %qD",
+ decl);
if (inlinep)
- {
- error ("%<inline%> is not allowed in declaration of friend "
- "template specialization %qD",
- decl);
- return NULL_TREE;
- }
+ return NULL_TREE;
}
}
@@ -7471,8 +7474,10 @@ grokfndecl (tree ctype,
{
if (PROCESSING_REAL_TEMPLATE_DECL_P())
error ("cannot declare %<::main%> to be a template");
- if (inlinep)
+ if (inlinep & 1)
error ("cannot declare %<::main%> to be inline");
+ if (inlinep & 2)
+ error ("cannot declare %<::main%> to be constexpr");
if (!publicp)
error ("cannot declare %<::main%> to be static");
inlinep = 0;
Index: testsuite/g++.dg/cpp0x/constexpr-friend-2.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-friend-2.C (revision 0)
+++ testsuite/g++.dg/cpp0x/constexpr-friend-2.C (working copy)
@@ -0,0 +1,7 @@
+// { dg-do compile { target c++11 } }
+
+template<typename T> void f(T);
+
+template <class T> class A {
+ friend constexpr void f<>(int); // { dg-error "'constexpr' is not allowed" }
+};
Index: testsuite/g++.dg/cpp0x/constexpr-main.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-main.C (revision 0)
+++ testsuite/g++.dg/cpp0x/constexpr-main.C (working copy)
@@ -0,0 +1,3 @@
+// { dg-do compile { target c++11 } }
+
+constexpr int main (); // { dg-error "constexpr" }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-26 3:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-25 23:40 [C++ Patch] Handle separately <inline> and <constexpr> in grokfndecl error messages Paolo Carlini
2013-03-26 3:09 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).