aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/inline-asm2.C
blob: 874e4cd3e299bb4e299d620c2e4b08e3d16ae448 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// P1668R1: Permit unevaluated inline asm in constexpr functions
// PR c++/91346
// { dg-do compile { target c++20 } }

constexpr int
foo (bool b)
{
  if (b)
    return 42;
  asm (""); // { dg-error "inline assembly is not a constant expression" }
// { dg-message "only unevaluated inline assembly" "" { target *-*-* } .-1 }
  return -1;
}

constexpr int i = foo (true);
static_assert(i == 42, "");
constexpr int j = foo (false); // { dg-message "in .constexpr. expansion of" }