]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/39413 (static_assert and SFINAE)
authorJason Merrill <jason@redhat.com>
Wed, 4 Nov 2009 22:29:35 +0000 (17:29 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 4 Nov 2009 22:29:35 +0000 (17:29 -0500)
PR c++/39413
* search.c (lookup_base): Don't complete_type (base).

From-SVN: r153920

gcc/cp/ChangeLog
gcc/cp/search.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/nested3.C
gcc/testsuite/g++.dg/template/overload11.C [new file with mode: 0644]

index 82104d280b56c8a710c19ce79b7bcb7b4a8ebeab..edf3ca86a96839fe619cfb1eb5c960dd57c2cc24 100644 (file)
@@ -1,5 +1,8 @@
 2009-11-04  Jason Merrill  <jason@redhat.com>
 
+       PR c++/39413
+       * search.c (lookup_base): Don't complete_type (base).
+
        PR c++/35067
        * method.c (use_thunk): Check DECL_WEAK as well as
        DECL_ONE_ONLY.
index d6521fb6f823ec942f9658061bc85ec498dd9084..356f3d6f52b532743bea83b84bb5bcc7b04dccf8 100644 (file)
@@ -214,9 +214,11 @@ lookup_base (tree t, tree base, base_access access, base_kind *kind_ptr)
       t_binfo = TYPE_BINFO (t);
     }
 
-  base = complete_type (TYPE_MAIN_VARIANT (base));
+  base = TYPE_MAIN_VARIANT (base);
 
-  if (t_binfo)
+  /* If BASE is incomplete, it can't be a base of T--and instantiating it
+     might cause an error.  */
+  if (t_binfo && (COMPLETE_TYPE_P (base) || TYPE_BEING_DEFINED (base)))
     {
       struct lookup_base_data_s data;
 
index 5f63688f2fcc8a18ebaefb9f826af2a05a38e77e..61f8450e081aa077064c10cbad96cdc804406be4 100644 (file)
@@ -1,3 +1,9 @@
+2009-11-04  Jason Merrill  <jason@redhat.com>
+
+       PR c++/39413
+       * g++.dg/template/overload11.C: New.
+       * g++.dg/template/nested3.C: Adjust.
+
 2009-11-04  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR ada/20548
index 1ae4bf7647d4ac4a05c68042809ad9baee9db615..5652e178a7034bd71ee5cd80ad75616aab98d479 100644 (file)
@@ -5,13 +5,13 @@ class A {
     int _k;
   };
   T1 _t1;
-  T2 _t2; // { dg-message "instantiated" }
+  T2 _t2;
 };
 
 template <class U>
-class B { // { dg-error "declaration" }
+class B {
   class SubB1 {
-    B _i; // { dg-error "incomplete type" }
+    B _i;
   };
 
   class SubB2 {
@@ -19,7 +19,6 @@ class B { // { dg-error "declaration" }
   };
   A<U,SubB1>::SubA<SubB2> _a; // { dg-error "not a base type" "not base" }
                // { dg-message "note" "note" { target *-*-* } 20 }
-               // { dg-message "instantiated" "inst" { target *-*-* } 20 }
                // { dg-error "non-template" "non-template" { target *-*-* } 20 }
 };
 
diff --git a/gcc/testsuite/g++.dg/template/overload11.C b/gcc/testsuite/g++.dg/template/overload11.C
new file mode 100644 (file)
index 0000000..d7b0a7c
--- /dev/null
@@ -0,0 +1,27 @@
+// PR c++/39413
+// We don't need to instantiate Wrapper<int> to check the
+// foo(const Thingy&) overload.
+
+template <class T> struct Incomplete;
+
+template <typename T> class Wrapper
+{
+  Incomplete<T> i;
+};
+
+template <typename T> struct Thingy
+{
+  Thingy();
+  Thingy(const Wrapper<T>& v);
+
+  template <typename X> void foo(const Thingy<X>&);
+  void foo(const Thingy&);
+};
+
+int main()
+{
+    Thingy<int> ap1;
+    Thingy<float> bp1;
+
+    ap1.foo(bp1);
+}
This page took 0.078805 seconds and 5 git commands to generate.