]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/53788 (C++11 decltype sfinae static member function check (4.7.1))
authorJason Merrill <jason@redhat.com>
Tue, 3 Jul 2012 03:30:09 +0000 (23:30 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 3 Jul 2012 03:30:09 +0000 (23:30 -0400)
PR c++/53788
* pt.c (build_non_dependent_expr): Don't wrap a dummy object.

From-SVN: r189188

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype39.C [new file with mode: 0644]
gcc/testsuite/g++.dg/diagnostic/method1.C

index f00ff70f8f10da8bcf57ecc552ee2c1f12b1bc82..e09166b59cf19714301e48c21ab93b9ef0bbbc7b 100644 (file)
@@ -1,5 +1,8 @@
 2012-07-02  Jason Merrill  <jason@redhat.com>
 
+       PR c++/53788
+       * pt.c (build_non_dependent_expr): Don't wrap a dummy object.
+
        PR c++/53816
        * class.c (resolves_to_fixed_type_p): Check uses_template_parms
        (current_function_decl) instead of processing_template_decl.
index f8f416a3b9ecac8628277dc4366cb99f3d334e9f..563a1ad294f9355ce9b0fa5a4a16526197bed5f7 100644 (file)
@@ -20215,6 +20215,10 @@ build_non_dependent_expr (tree expr)
   if (BRACE_ENCLOSED_INITIALIZER_P (expr))
     return expr;
 
+  /* Don't wrap a dummy object, we need to be able to test for it.  */
+  if (is_dummy_object (expr))
+    return expr;
+
   if (TREE_CODE (expr) == COND_EXPR)
     return build3 (COND_EXPR,
                   TREE_TYPE (expr),
index fc712849a65a4d282470c03a8933d6e285572c43..56b83e44eaa096f963aa46b46b088f9d5bdf056d 100644 (file)
@@ -1,5 +1,9 @@
 2012-07-02  Jason Merrill  <jason@redhat.com>
 
+       PR c++/53788
+       * g++.dg/cpp0x/decltype39.C: New.
+       * g++.dg/diagnostic/method1.C: Adjust.
+
        PR c++/53816
        * g++.dg/template/ref6.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype39.C b/gcc/testsuite/g++.dg/cpp0x/decltype39.C
new file mode 100644 (file)
index 0000000..4676d2d
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/53788
+// { dg-do compile { target c++11 } }
+
+struct t { static const bool value = true; };
+struct f { static const bool value = false; };
+
+template<typename T>
+struct has_static {
+  template<typename X>
+  static t check(X*, decltype(T::fun())* = 0); // { dg-error "without object" }
+  static f check(...);
+
+  typedef decltype(check((T*)(0))) ret;
+  static const bool value = ret::value;
+};
+
+struct test { int fun() { return 0; } };
+
+bool b = has_static<test>::value;
index 4a781047ef882d18456e7e31db069a43f70d11e5..0e7c580924a142e04cec7cc963cc1fbb03187d35 100644 (file)
@@ -10,7 +10,7 @@ template <class T>
 void
 bar ()
 {
-  A::foo ().anything;  // { dg-error "request for member" }
+  A::foo ().anything;  // { dg-error "without object" }
 }
 
 void
@@ -18,5 +18,3 @@ baz ()
 {
   bar <int> ();
 }
-
-// { dg-prune-output "without object" }