commit 66f75d714661171ff026b8ccf3d99ce9a4d536e2
Author: Jason Merrill <jason@redhat.com>
Date: Mon Jul 2 17:06:33 2012 -0400
PR c++/53788
* pt.c (build_non_dependent_expr): Don't wrap a dummy object.
@@ -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),
new file mode 100644
@@ -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;
@@ -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" }