efriedma added a comment.

Do we need CodeGen testcases here for full coverage?  The testcases from the 
issue passed with -fsyntax-only.

--------

With this patch, the following cases produce errors that don't really make 
sense to me:

  consteval int f(int x) {
      return x;
  }
  struct SS {
      int y;
      int x = f(this->y);
      constexpr SS(int yy) : y(yy) {}
  };
  SS s = {1};



  <stdin>:6:13: error: call to consteval function 'f' is not a constant 
expression
      6 |     int x = f(this->y);
        |             ^
  <stdin>:7:15: note: in the default initializer of 'x'
      7 |     constexpr SS(int yy) : y(yy) {}
        |               ^
  <stdin>:6:5: note: declared here
      6 |     int x = f(this->y);
        |     ^
  <stdin>:6:15: note: use of 'this' pointer is only allowed within the 
evaluation of a call to a 'constexpr' member function
      6 |     int x = f(this->y);
        |               ^
  1 error generated.



  consteval int f(int x) {
      return x;
  }
  struct SS {
      int y;
      int x = f(this->y);
      consteval SS(int yy) : y(yy) {}
  };
  SS s = {1};

  <stdin>:6:13: error: cannot take address of consteval function 'f' outside of 
an immediate invocation
      6 |     int x = f(this->y);
        |             ^
  <stdin>:1:15: note: declared here
      1 | consteval int f(int x) {
        |               ^
  1 error generated.

Somehow the following is accepted, though:

  consteval int f(int x) {
      return x;
  }
  struct SS {
      int y;
      int x = f(this->y);
      template<typename T> constexpr SS(T yy) : y(yy) {}
  };
  SS s = {1};


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155175

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

Reply via email to