From: Paolo Carlini <paolo.carlini@oracle.com>
To: Jason Merrill <jason@redhat.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ Patch] PR 50732
Date: Fri, 14 Oct 2011 23:03:00 -0000 [thread overview]
Message-ID: <4E98B07E.6060409@oracle.com> (raw)
In-Reply-To: <4E9888AC.8070605@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 659 bytes --]
On 10/14/2011 09:08 PM, Jason Merrill wrote:
> How about using complete_type_or_else?
The CPTK_IS_BASE_OF case becomes much simpler indeed, thanks. For the
unary traits, though, I don't see an advantage in using it, because in
some cases in check_trait_type we don't want to error out even when
complete_type_or_else would. Unless we can check whether we are dealing
with an array of unknown bound *before* completing the type? That is:
if (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type)
&& COMPLETE_TYPE_P (TREE_TYPE (type)))
is the outcome always the same before and after trying to complete (type)?
Thanks,
Paolo.
//////////////////////
[-- Attachment #2: patch_50732_2 --]
[-- Type: text/plain, Size: 2111 bytes --]
Index: testsuite/g++.dg/ext/is_base_of_diagnostic.C
===================================================================
--- testsuite/g++.dg/ext/is_base_of_diagnostic.C (revision 180007)
+++ testsuite/g++.dg/ext/is_base_of_diagnostic.C (working copy)
@@ -1,7 +1,7 @@
class A
{ };
-class B;
+class B; // { dg-error "forward declaration" }
union C
{ };
Index: testsuite/g++.dg/ext/is_base_of_incomplete.C
===================================================================
--- testsuite/g++.dg/ext/is_base_of_incomplete.C (revision 0)
+++ testsuite/g++.dg/ext/is_base_of_incomplete.C (revision 0)
@@ -0,0 +1,7 @@
+template <typename T>
+struct non_instantiable
+{
+ typedef typename T::THIS_TYPE_CANNOT_BE_INSTANTIATED type;
+};
+
+int check[__is_base_of(non_instantiable<int>, void) ? -1 : 1];
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 180007)
+++ cp/semantics.c (working copy)
@@ -5276,10 +5276,6 @@ finish_trait_expr (cp_trait_kind kind, tree type1,
return trait_expr;
}
- complete_type (type1);
- if (type2)
- complete_type (type2);
-
switch (kind)
{
case CPTK_HAS_NOTHROW_ASSIGN:
@@ -5297,9 +5293,10 @@ finish_trait_expr (cp_trait_kind kind, tree type1,
case CPTK_IS_POLYMORPHIC:
case CPTK_IS_STD_LAYOUT:
case CPTK_IS_TRIVIAL:
+ complete_type (type1);
if (!check_trait_type (type1))
{
- error ("incomplete type %qT not allowed", type1);
+ error ("invalid use of incomplete type %qT", type1);
return error_mark_node;
}
break;
@@ -5307,11 +5304,9 @@ finish_trait_expr (cp_trait_kind kind, tree type1,
case CPTK_IS_BASE_OF:
if (NON_UNION_CLASS_TYPE_P (type1) && NON_UNION_CLASS_TYPE_P (type2)
&& !same_type_ignoring_top_level_qualifiers_p (type1, type2)
- && !COMPLETE_TYPE_P (type2))
- {
- error ("incomplete type %qT not allowed", type2);
- return error_mark_node;
- }
+ && !complete_type_or_else (type2, NULL_TREE))
+ /* We already issued an error. */
+ return error_mark_node;
break;
case CPTK_IS_CLASS:
next prev parent reply other threads:[~2011-10-14 22:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-14 18:48 Paolo Carlini
2011-10-14 18:56 ` Paolo Carlini
2011-10-14 19:12 ` Paolo Carlini
2011-10-14 19:41 ` Jason Merrill
2011-10-14 23:03 ` Paolo Carlini [this message]
2011-10-14 23:26 ` Jason Merrill
2011-10-15 1:17 ` Paolo Carlini
2011-10-15 20:42 ` Jason Merrill
2011-10-15 21:21 ` Paolo Carlini
2011-10-15 21:27 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E98B07E.6060409@oracle.com \
--to=paolo.carlini@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).