[PATCH] D77395: [AST] Dont invalidate VarDecl even the default initializaiton is failed.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 3 07:29:59 PDT 2020


hokein created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hokein edited the summary of this revision.
hokein edited the summary of this revision.
hokein added a reviewer: sammccall.
hokein retitled this revision from "[AST] Dont invalide VarDecl even the default initializaiton is failed." to "[AST] Dont invalidate VarDecl even the default initializaiton is failed.".

This patch would cause clang emit more diagnostics, but it is much better than https://reviews.llvm.org/D76831

  cpp
  struct A {
    A(int);
    ~A() = delete;
  };
  void k() {
    A a;
  }

before the patch:

  /tmp/t3.cpp:24:5: error: no matching constructor for initialization of 'A'
    A a;
      ^
  /tmp/t3.cpp:20:3: note: candidate constructor not viable: requires 1 argument, but 0 were provided
    A(int);
    ^
  /tmp/t3.cpp:19:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
  struct A {

After the patch:

  /tmp/t3.cpp:24:5: error: no matching constructor for initialization of 'A'
    A a;
      ^
  /tmp/t3.cpp:20:3: note: candidate constructor not viable: requires 1 argument, but 0 were provided
    A(int);
    ^
  /tmp/t3.cpp:19:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
  struct A {
         ^
  /tmp/t3.cpp:24:5: error: attempt to use a deleted function
    A a;
      ^
  /tmp/t3.cpp:21:3: note: '~A' has been explicitly marked deleted here
    ~A() = delete;


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77395

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-invalid-initialized.cpp
  clang/test/CXX/class.access/p4.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/special/class.ctor/p5-0x.cpp
  clang/test/CodeCompletion/invalid-initialized-class.cpp
  clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
  clang/test/SemaObjCXX/arc-0x.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77395.254793.patch
Type: text/x-patch
Size: 17102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200403/ce798b8c/attachment-0001.bin>


More information about the cfe-commits mailing list