public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 50732
@ 2011-10-14 18:48 Paolo Carlini
  2011-10-14 18:56 ` Paolo Carlini
  0 siblings, 1 reply; 10+ messages in thread
From: Paolo Carlini @ 2011-10-14 18:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 316 bytes --]

Hi,

submitter complains that, at variance with C++11, __is_base_of doesn't 
handle an incomplete base type (the first parameter). The reason seems 
simple: in finish_trait_expr we try to complete *both* types instead of 
doing it where/when necessary.

Tested x86_64-linux. Ok?

Thanks,
Paolo.

///////////////////

[-- Attachment #2: CL_50732 --]
[-- Type: text/plain, Size: 305 bytes --]

/cp
2011-10-14  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50732
	* semantics.c (finish_trait_expr): Do not try to instantiate the
	the base type of an __is_base_of trait.

/testsuite
2011-10-14  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50732
	* g++.dg/ext/is_base_of_incomplete.C: New.

[-- Attachment #3: patch_50732 --]
[-- Type: text/plain, Size: 1449 bytes --]

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 179997)
+++ 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,6 +5293,7 @@ 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);
@@ -5305,6 +5302,7 @@ finish_trait_expr (cp_trait_kind kind, tree type1,
       break;
 
     case CPTK_IS_BASE_OF:
+      complete_type (type2);
       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))

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-10-15 19:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-14 18:48 [C++ Patch] PR 50732 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
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

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).