erichkeane added inline comments.

================
Comment at: clang/test/Sema/builtin-expect-with-probability.cpp:17
+constexpr int constf() {
+  return __builtin_expect_with_probability(1, 1, 1); // should not have error 
here
+}
----------------
I mean something more like:

    template<int b>
    void foo() { static_assert(!b,""); } // expected-error {{....}}

    void bar() {
      foo<__builtin_expect_with_probability(1,1,1)>();
    }


This example doesn't require that constf is executed at compile time.  You'd 
need to either send the result of constf to a template, or assign it to a 
constexpr variable in order to make it work.

So something like:

    void foo() {
       constexpr int f = constf();
       static_assert(f == 1, "");
    }



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83362/new/

https://reviews.llvm.org/D83362



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to