[PATCH] D122935: [AST] Dont invalidate a ref-type var decl if it has no initializer.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 25 06:15:01 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc673d67bc76b: [AST] Dont invalidate a ref-type var decl if it has no initializer. (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122935/new/
https://reviews.llvm.org/D122935
Files:
clang/lib/Sema/SemaDecl.cpp
clang/test/AST/ast-dump-invalid-initialized.cpp
Index: clang/test/AST/ast-dump-invalid-initialized.cpp
===================================================================
--- clang/test/AST/ast-dump-invalid-initialized.cpp
+++ clang/test/AST/ast-dump-invalid-initialized.cpp
@@ -12,10 +12,10 @@
const A a2;
// CHECK: `-VarDecl {{.*}} a3 'A'
A a3 = garbage();
+ // CHECK: `-VarDecl {{.*}} a4 'const A &'
+ const A& a4;
- // CHECK: `-VarDecl {{.*}} invalid b1 'const A &'
- const A& b1;
// CHECK: `-VarDecl {{.*}} invalid b2 'ForwardDecl'
ForwardDecl b2;
// CHECK: `-VarDecl {{.*}} invalid b3 'auto'
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13199,7 +13199,6 @@
if (Type->isReferenceType()) {
Diag(Var->getLocation(), diag::err_reference_var_requires_init)
<< Var << SourceRange(Var->getLocation(), Var->getLocation());
- Var->setInvalidDecl();
return;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122935.431961.patch
Type: text/x-patch
Size: 1002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220525/7f6ef382/attachment-0001.bin>
More information about the cfe-commits
mailing list