Do constexpr expansion of expressions where the call itself is not
constant, but the call followed by an INDIRECT_REF is. */
if (callee && DECL_DECLARED_CONSTEXPR_P (callee)
- && !flag_no_inline)
+ && (!flag_no_inline
+ || lookup_attribute ("always_inline",
+ DECL_ATTRIBUTES (callee))))
{
mce_value manifestly_const_eval = mce_unknown;
if (flags & ff_mce_false)
// { dg-do compile { target c++11 } }
// { dg-skip-if "" { powerpc-ibm-aix* } }
-// { dg-options "-gpubnames -gdwarf-4 -fno-debug-types-section -dA -fno-inline" }
+// { dg-options "-gpubnames -gdwarf-4 -fno-debug-types-section -dA -fno-inline -fno-implicit-constexpr" }
// { dg-final { scan-assembler-times "\.section\[\t \]\[^\n\]*debug_pubnames" 1 } }
// { dg-final { scan-assembler "\"\\(anonymous namespace\\)\\\\0\"+\[ \t\]+\[#;/|@!]+\[ \t\]+external name" } }
// { dg-final { scan-assembler "\"one\\\\0\"+\[ \t\]+\[#;/|@!]+\[ \t\]+external name" } }
// { dg-do compile { target c++11 } }
// { dg-skip-if "" { powerpc-ibm-aix* } }
-// { dg-options "-gpubnames -gdwarf-4 -fdebug-types-section -dA -fno-inline" }
+// { dg-options "-gpubnames -gdwarf-4 -fdebug-types-section -dA -fno-inline -fno-implicit-constexpr" }
// { dg-final { scan-assembler-times "\.section\[\t \]\[^\n\]*debug_pubnames" 1 } }
// { dg-final { scan-assembler "\"\\(anonymous namespace\\)\\\\0\"+\[ \t\]+\[#;/|@!]+\[ \t\]+external name" } }
// { dg-final { scan-assembler "\"one\\\\0\"+\[ \t\]+\[#;/|@!]+\[ \t\]+external name" } }
--- /dev/null
+// PR c++/120935
+// { dg-additional-options "-fdump-tree-optimized" }
+// { dg-final { scan-tree-dump-not "goto" "optimized" } }
+// { dg-do compile { target c++11 } }
+
+void x(int);
+
+[[gnu::always_inline]] constexpr bool
+is_constant_evaluated()
+{ return __builtin_is_constant_evaluated(); }
+
+struct Iter
+{
+ typedef int value_type;
+
+ int& operator*() const;
+ Iter& operator++();
+ bool operator!=(const Iter&) const;
+};
+
+void f(Iter first, Iter last)
+{
+ if (__is_trivial(Iter::value_type))
+ if (!is_constant_evaluated())
+ return;
+ for (; first != last; ++first)
+ x(*first);
+}