diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -5593,7 +5593,8 @@ // C++ [dcl.init]p16.6.2.2 // The remaining elements are initialized with their default // member initializers, if any - ExprResult DIE = S.BuildCXXDefaultInitExpr(FD->getLocation(), FD); + ExprResult DIE = S.BuildCXXDefaultInitExpr( + Kind.getParenOrBraceRange().getEnd(), FD); if (DIE.isInvalid()) return; S.checkInitializerLifetime(SubEntity, DIE.get()); diff --git a/clang/test/SemaCXX/source_location.cpp b/clang/test/SemaCXX/source_location.cpp --- a/clang/test/SemaCXX/source_location.cpp +++ b/clang/test/SemaCXX/source_location.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s // RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions -verify %s +// RUN: %clang_cc1 -std=c++2b -fcxx-exceptions -DUSE_CONSTEVAL -DPAREN_INIT -fexceptions -verify %s // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fms-extensions -DMS -fexceptions -verify %s // RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fms-extensions -DMS -DUSE_CONSTEVAL -fexceptions -verify %s // expected-no-diagnostics @@ -781,3 +782,17 @@ static_assert(f() != // intentional new line f()); } + +#ifdef PAREN_INIT +namespace GH63903 { +struct S { + int _; + int i = SL::current().line(); + int j = __builtin_LINE(); +}; +// Ensure parent aggregate initialization is consistent with brace +// aggregate initialization. +static_assert(S(0).i == S{0}.i); +static_assert(S(0).j == S{0}.i); +} +#endif