diff --git a/gcc/cp/expr.cc b/gcc/cp/expr.cc index 31fe0980337..56fc11f425b 100644 --- a/gcc/cp/expr.cc +++ b/gcc/cp/expr.cc @@ -397,6 +397,11 @@ fold_for_warn (tree x) { /* C++ implementation. */ + if (cp_unevaluated_operand) + /* In an unevaluated context we don't care about the reduced value + of an expression, so neither should any warnings. */ + return x; + /* Prevent warning-dependent constexpr evaluation from changing DECL_UID (which breaks -fcompare-debug) and from instantiating templates. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype82a.C b/gcc/testsuite/g++.dg/cpp0x/decltype82a.C new file mode 100644 index 00000000000..cbbcdfd8e58 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype82a.C @@ -0,0 +1,11 @@ +// PR c++/105931 +// { dg-do compile { target c++11 } } +// A version of decltype82.C where N is unsigned. + +template +void f() { + using ty1 = decltype((5 % N) == 0); + using ty2 = decltype((5 / N) == 0); +} + +template void f<0>();