[all-commits] [llvm/llvm-project] 965738: [AST] Dont invalide VarDecl even the default initi...

Haojian Wu via All-commits all-commits at lists.llvm.org
Tue Apr 14 04:00:22 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9657385960350150b77ed652175b4c3801abd7fa
      https://github.com/llvm/llvm-project/commit/9657385960350150b77ed652175b4c3801abd7fa
  Author: Haojian Wu <hokein.wu at gmail.com>
  Date:   2020-04-14 (Tue, 14 Apr 2020)

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

  Log Message:
  -----------
  [AST] Dont invalide VarDecl even the default initializaiton is failed.

Summary:
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;

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77395




More information about the All-commits mailing list