[PATCH] D117391: [AST] Ignore implicit nodes in CastExpr::getConversionFunction

Kim Gräsman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 2 12:02:17 PST 2022


kimgr added a comment.

Here's the diff between my patch (main) and handling `FullExpr` in `skipImplicitTemporary` as in the diff I posted above (patch.txt):

  --- main.txt	2022-02-02 20:37:21.619534225 +0100
  +++ patch.txt	2022-02-02 20:34:17.016949227 +0100
  @@ -192,6 +192,13 @@
   /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:360:25: note: temporary created here
     { A k = to_lvalue_ref(A()); } // expected-error {{is not a constant expression}}
                           ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:362:25: error: call to consteval function 'alloc::A::ret_a' is not a constant expression
  +  { A k = to_lvalue_ref(A().ret_a()); } // expected-error {{is not a constant expression}}
  +                        ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:362:25: note: pointer to heap-allocated object is not a constant expression
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:334:12: note: heap allocation performed here
  +  int* p = new int(42);
  +           ^
   /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:362:11: error: call to consteval function 'alloc::to_lvalue_ref' is not a constant expression
     { A k = to_lvalue_ref(A().ret_a()); } // expected-error {{is not a constant expression}}
             ^
  @@ -199,6 +206,27 @@
   /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:362:25: note: temporary created here
     { A k = to_lvalue_ref(A().ret_a()); } // expected-error {{is not a constant expression}}
                           ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:364:13: error: call to consteval function 'alloc::A::ret_a' is not a constant expression
  +  { int k = A().ret_a().ret_i(); }
  +            ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:364:13: note: pointer to heap-allocated object is not a constant expression
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:334:12: note: heap allocation performed here
  +  int* p = new int(42);
  +           ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:370:25: error: call to consteval function 'alloc::A::ret_a' is not a constant expression
  +  { int k = const_a_ref(A().ret_a()); }
  +                        ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:370:25: note: pointer to heap-allocated object is not a constant expression
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:334:12: note: heap allocation performed here
  +  int* p = new int(42);
  +           ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:371:39: error: call to consteval function 'alloc::A::ret_a' is not a constant expression
  +  { int k = const_a_ref(to_lvalue_ref(A().ret_a())); }
  +                                      ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:371:39: note: pointer to heap-allocated object is not a constant expression
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:334:12: note: heap allocation performed here
  +  int* p = new int(42);
  +           ^
   /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:375:14: error: call to consteval function 'alloc::A::ret_a' is not a constant expression
     { int k = (A().ret_a(), A().ret_i()); }// expected-error {{is not a constant expression}}
                ^
  @@ -206,6 +234,13 @@
   /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:334:12: note: heap allocation performed here
     int* p = new int(42);
              ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:377:26: error: call to consteval function 'alloc::A::ret_a' is not a constant expression
  +  { int k = (const_a_ref(A().ret_a()), A().ret_i()); }
  +                         ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:377:26: note: pointer to heap-allocated object is not a constant expression
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:334:12: note: heap allocation performed here
  +  int* p = new int(42);
  +           ^
   /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:400:7: error: call to consteval function 'self_referencing::f' is not a constant expression
     s = f(0); // expected-error {{is not a constant expression}}
         ^
  @@ -454,9 +489,9 @@
   /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:548:15: note: declared here
   consteval int f_eval() { // expected-note+ {{declared here}}
                 ^
  -/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:574:25: error: cannot take address of consteval function 'f_eval' outside of an immediate invocation
  -  { Copy c = Copy(Copy(&f_eval)); }// expected-error {{cannot take address of consteval}}
  -                        ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:567:19: error: cannot take address of consteval function 'f_eval' outside of an immediate invocation
  +  { Copy c((Copy(&f_eval))); }// expected-error {{cannot take address of consteval}}
  +                  ^
   /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:548:15: note: declared here
   consteval int f_eval() { // expected-note+ {{declared here}}
                 ^
  @@ -466,9 +501,9 @@
   /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:548:15: note: declared here
   consteval int f_eval() { // expected-note+ {{declared here}}
                 ^
  -/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:567:19: error: cannot take address of consteval function 'f_eval' outside of an immediate invocation
  -  { Copy c((Copy(&f_eval))); }// expected-error {{cannot take address of consteval}}
  -                  ^
  +/home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:574:25: error: cannot take address of consteval function 'f_eval' outside of an immediate invocation
  +  { Copy c = Copy(Copy(&f_eval)); }// expected-error {{cannot take address of consteval}}
  +                        ^
   /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:548:15: note: declared here
   consteval int f_eval() { // expected-note+ {{declared here}}
                 ^
  @@ -501,4 +536,4 @@
       a() + d(); // expected-error {{call to consteval function 'PR48235::A::a' is not a constant expression}} \
       ^
   /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp:661:5: note: implicit use of 'this' pointer is only allowed within the evaluation of a call to a 'constexpr' member function
  -84 errors generated.
  +89 errors generated.

It looks to my untrained eye as if these additional diagnostics might be correct. But I'm not sure. Help, please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117391



More information about the cfe-commits mailing list