+2020-05-18 Marek Polacek <polacek@redhat.com>
+
+ PR c++/94937
+ * cvt.c (cp_get_fndecl_from_callee): Return NULL_TREE if the function
+ type is not INDIRECT_TYPE_P.
+ * decl.c (omp_declare_variant_finalize_one): Call
+ cp_get_callee_fndecl_nofold instead of looking for the function decl
+ manually.
+
2020-05-18 Marek Polacek <polacek@redhat.com>
PR c++/90915
if (TREE_CODE (fn) == FUNCTION_DECL)
return fn;
tree type = TREE_TYPE (fn);
- if (type == unknown_type_node)
+ if (type == NULL_TREE || !INDIRECT_TYPE_P (type))
return NULL_TREE;
- gcc_assert (INDIRECT_TYPE_P (type));
if (fold)
fn = maybe_constant_init (fn);
STRIP_NOPS (fn);
if (variant == error_mark_node && !processing_template_decl)
return true;
- variant = cp_get_callee (variant);
- if (variant)
- {
- if (TREE_CODE (variant) == FUNCTION_DECL)
- ;
- else if (TREE_TYPE (variant) && INDIRECT_TYPE_P (TREE_TYPE (variant)))
- variant = cp_get_fndecl_from_callee (variant, false);
- else
- variant = NULL_TREE;
- }
-
+ variant = cp_get_callee_fndecl_nofold (variant);
input_location = save_loc;
if (variant)
+2020-05-18 Marek Polacek <polacek@redhat.com>
+
+ PR c++/94937
+ * g++.dg/cpp1z/constexpr-if34.C: New test.
+ * g++.dg/cpp2a/is-constant-evaluated10.C: New test.
+
2020-05-18 Martin Sebor <msebor@redhat.com>
PR middle-end/92815
--- /dev/null
+// PR c++/94937 - ICE with -Wall and constexpr if.
+// { dg-do compile { target c++17 } }
+// { dg-options "-Wall" }
+
+struct B {
+ static constexpr bool foo() { return false; }
+};
+
+template<typename T>
+struct C {
+ static void bar ()
+ {
+ if constexpr (B::foo()) ;
+ }
+};
--- /dev/null
+// { dg-do compile { target c++2a } }
+// { dg-options "-Wtautological-compare" }
+
+namespace std {
+ constexpr inline bool
+ is_constant_evaluated () noexcept
+ {
+ return __builtin_is_constant_evaluated ();
+ }
+}
+
+template<typename>
+constexpr int
+foo(int i)
+{
+ if constexpr (std::is_constant_evaluated ()) // { dg-warning ".std::is_constant_evaluated. always evaluates to true in .if constexpr." }
+ return 42;
+ else
+ return i;
+}
+
+template<typename>
+constexpr int
+foo2(int i)
+{
+ if constexpr (__builtin_is_constant_evaluated ()) // { dg-warning ".std::is_constant_evaluated. always evaluates to true in .if constexpr." }
+ return 42;
+ else
+ return i;
+}