hliao updated this revision to Diff 395248. hliao added a comment. Revise the formatting.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D115976/new/ https://reviews.llvm.org/D115976 Files: clang/include/clang/AST/Expr.h clang/lib/Sema/SemaInit.cpp clang/test/SemaCXX/uninitialized.cpp Index: clang/test/SemaCXX/uninitialized.cpp =================================================================== --- clang/test/SemaCXX/uninitialized.cpp +++ clang/test/SemaCXX/uninitialized.cpp @@ -1472,3 +1472,20 @@ }; }; Outer<int>::Inner outerinner; + +namespace crash_on_report_uninitialized_field { +struct S { + union { + struct { + const int &f0; + const float &f1; // expected-note{{uninitialized reference member is here}} + }; + double d; + }; +}; +void bar(struct S &s); +void foo(int i, float f) { + S s = {.f0 = i}; // expected-error{{reference member of type 'const float &' uninitialized}} + bar(s); +} +} // namespace crash_on_report_uninitialized_field Index: clang/lib/Sema/SemaInit.cpp =================================================================== --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -695,8 +695,7 @@ // member of reference type uninitialized, the program is // ill-formed. SemaRef.Diag(Loc, diag::err_init_reference_member_uninitialized) - << Field->getType() - << ILE->getSyntacticForm()->getSourceRange(); + << Field->getType() << ILE->getSourceRange(); SemaRef.Diag(Field->getLocation(), diag::note_uninit_reference_member); } Index: clang/include/clang/AST/Expr.h =================================================================== --- clang/include/clang/AST/Expr.h +++ clang/include/clang/AST/Expr.h @@ -4964,6 +4964,9 @@ SourceLocation getBeginLoc() const LLVM_READONLY; SourceLocation getEndLoc() const LLVM_READONLY; + SourceRange getSourceRange() const LLVM_READONLY { + return SourceRange(getBeginLoc(), getEndLoc()); + } static bool classof(const Stmt *T) { return T->getStmtClass() == InitListExprClass;
Index: clang/test/SemaCXX/uninitialized.cpp =================================================================== --- clang/test/SemaCXX/uninitialized.cpp +++ clang/test/SemaCXX/uninitialized.cpp @@ -1472,3 +1472,20 @@ }; }; Outer<int>::Inner outerinner; + +namespace crash_on_report_uninitialized_field { +struct S { + union { + struct { + const int &f0; + const float &f1; // expected-note{{uninitialized reference member is here}} + }; + double d; + }; +}; +void bar(struct S &s); +void foo(int i, float f) { + S s = {.f0 = i}; // expected-error{{reference member of type 'const float &' uninitialized}} + bar(s); +} +} // namespace crash_on_report_uninitialized_field Index: clang/lib/Sema/SemaInit.cpp =================================================================== --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -695,8 +695,7 @@ // member of reference type uninitialized, the program is // ill-formed. SemaRef.Diag(Loc, diag::err_init_reference_member_uninitialized) - << Field->getType() - << ILE->getSyntacticForm()->getSourceRange(); + << Field->getType() << ILE->getSourceRange(); SemaRef.Diag(Field->getLocation(), diag::note_uninit_reference_member); } Index: clang/include/clang/AST/Expr.h =================================================================== --- clang/include/clang/AST/Expr.h +++ clang/include/clang/AST/Expr.h @@ -4964,6 +4964,9 @@ SourceLocation getBeginLoc() const LLVM_READONLY; SourceLocation getEndLoc() const LLVM_READONLY; + SourceRange getSourceRange() const LLVM_READONLY { + return SourceRange(getBeginLoc(), getEndLoc()); + } static bool classof(const Stmt *T) { return T->getStmtClass() == InitListExprClass;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits