summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-03 18:43:06 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-03 18:43:06 +0000
commit7d9261266b7cc2aa97a631339e3ffc8643e7f59a (patch)
tree8a425ade42a069bc27caf86c3a2b7a4918ff3ec5
parent4bbaf9cf22e552ae015cc0a4d75709c416c903f3 (diff)
downloadgcc-7d9261266b7cc2aa97a631339e3ffc8643e7f59a.tar.gz
PR c++/41927
* typeck.c (build_x_binary_op): Don't do warn_parentheses if we're in a SFINAE context. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153863 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/typeck.c1
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/template/sfinae16.C34
4 files changed, 42 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a04b6e74d49..d7b3150e216 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2009-11-03 Jason Merrill <jason@redhat.com>
+ PR c++/41927
+ * typeck.c (build_x_binary_op): Don't do warn_parentheses
+ if we're in a SFINAE context.
+
PR c++/41815
* call.c (build_call_a): Strip cv-quals from rvalue result.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 5b8523d8bd6..7cafc8ab224 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3245,6 +3245,7 @@ build_x_binary_op (enum tree_code code, tree arg1, enum tree_code arg1_code,
misinterpret. But don't warn about obj << x + y, since that is a
common idiom for I/O. */
if (warn_parentheses
+ && (complain & tf_warning)
&& !processing_template_decl
&& !error_operand_p (arg1)
&& !error_operand_p (arg2)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0371d4a27fc..dc49db07803 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2009-11-03 Jason Merrill <jason@redhat.com>
+ PR c++/41927
+ * g++.dg/template/sfinae16.C: New.
+
PR c++/41815
* g++.dg/cpp0x/rv-return.C: New.
* g++.dg/cpp0x/deduce.C: Adjust.
diff --git a/gcc/testsuite/g++.dg/template/sfinae16.C b/gcc/testsuite/g++.dg/template/sfinae16.C
new file mode 100644
index 00000000000..5ea564c9f86
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/sfinae16.C
@@ -0,0 +1,34 @@
+// PR c++/41927
+// { dg-options "-std=c++0x -Wall" }
+
+// We were getting a spurious ||/&& warning about the enable_if with the
+// source position of d1.
+
+template<typename Tp>
+ struct is_int
+ { static const bool value = true; };
+
+template<bool, typename Tp = void>
+ struct enable_if
+ { };
+
+template<typename Tp>
+ struct enable_if<true, Tp>
+ { typedef Tp type; };
+
+template<typename Rep>
+ struct duration
+ {
+ duration() { }
+
+ template<typename Rep2, typename = typename
+ enable_if<false || (true && is_int<Rep2>::value)>::type>
+ duration(const duration<Rep2>&) { }
+ };
+
+int main()
+{
+ duration<int> d0;
+ duration<int> d1 = d0;
+}
+