Re: r332286 - PR37450: Fix bug that disabled some type checks for variables with deduced types.
Should be fixed in r332425. Apologies for the delay addressing this. On 15 May 2018 at 18:10, Richard Smithwrote: > Sorry for the delay, looking now. > > On 15 May 2018 at 02:24, Maxim Kuvyrkov wrote: > >> Hi Richard, >> >> The for-range-examples.cpp test fails on 32-bit arm buildbots, e.g.: >> http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/840 . >> Would you please investigate? >> >> You didn't get a notification because your commit was around the same >> time as a fix for an unrelated testcase issue that caused same bots to be >> red. >> >> -- >> Maxim Kuvyrkov >> www.linaro.org >> >> >> >> > On May 14, 2018, at 11:15 PM, Richard Smith via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> > >> > Author: rsmith >> > Date: Mon May 14 13:15:04 2018 >> > New Revision: 332286 >> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=332286=rev >> > Log: >> > PR37450: Fix bug that disabled some type checks for variables with >> deduced types. >> > >> > Also improve diagnostic for the case where a type is non-literal >> because it's a lambda. >> > >> > Modified: >> >cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> >cfe/trunk/lib/Sema/SemaDecl.cpp >> >cfe/trunk/lib/Sema/SemaType.cpp >> >cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp >> >cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp >> >cfe/trunk/test/SemaCXX/for-range-examples.cpp >> > >> > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >> Basic/DiagnosticSemaKinds.td?rev=332286=332285=332286=diff >> > >> == >> > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) >> > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May 14 >> 13:15:04 2018 >> > @@ -2381,6 +2381,8 @@ def note_non_literal_user_provided_dtor >> > "%0 is not literal because it has a user-provided destructor">; >> > def note_non_literal_nontrivial_dtor : Note< >> > "%0 is not literal because it has a non-trivial destructor">; >> > +def note_non_literal_lambda : Note< >> > + "lambda closure types are non-literal types before C++17">; >> > def warn_private_extern : Warning< >> > "use of __private_extern__ on a declaration may not produce external >> symbol " >> > "private to the linkage unit and is deprecated">, >> InGroup; >> > >> > Modified: cfe/trunk/lib/Sema/SemaDecl.cpp >> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaD >> ecl.cpp?rev=332286=332285=332286=diff >> > >> == >> > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) >> > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May 14 13:15:04 2018 >> > @@ -7293,8 +7293,7 @@ void Sema::CheckVariableDeclarationType( >> > if (NewVD->isInvalidDecl()) >> > return; >> > >> > - TypeSourceInfo *TInfo = NewVD->getTypeSourceInfo(); >> > - QualType T = TInfo->getType(); >> > + QualType T = NewVD->getType(); >> > >> > // Defer checking an 'auto' type until its initializer is attached. >> > if (T->isUndeducedType()) >> > @@ -7438,10 +7437,18 @@ void Sema::CheckVariableDeclarationType( >> > (T->isVariableArrayType() && NewVD->hasGlobalStorage())) { >> > bool SizeIsNegative; >> > llvm::APSInt Oversized; >> > -TypeSourceInfo *FixedTInfo = >> > - TryToFixInvalidVariablyModifiedTypeSourceInfo(TInfo, Context, >> > -SizeIsNegative, >> Oversized); >> > -if (!FixedTInfo && T->isVariableArrayType()) { >> > +TypeSourceInfo *FixedTInfo = TryToFixInvalidVariablyModifie >> dTypeSourceInfo( >> > +NewVD->getTypeSourceInfo(), Context, SizeIsNegative, >> Oversized); >> > +QualType FixedT; >> > +if (FixedTInfo && T == NewVD->getTypeSourceInfo()->getType()) >> > + FixedT = FixedTInfo->getType(); >> > +else if (FixedTInfo) { >> > + // Type and type-as-written are canonically different. We need >> to fix up >> > + // both types separately. >> > + FixedT = TryToFixInvalidVariablyModifiedType(T, Context, >> SizeIsNegative, >> > + Oversized); >> > +} >> > +if ((!FixedTInfo || FixedT.isNull()) && T->isVariableArrayType()) { >> > const VariableArrayType *VAT = Context.getAsVariableArrayType(T); >> > // FIXME: This won't give the correct result for >> > // int a[10][n]; >> > @@ -7470,7 +7477,7 @@ void Sema::CheckVariableDeclarationType( >> > } >> > >> > Diag(NewVD->getLocation(), diag::warn_illegal_constant_array_size); >> > -NewVD->setType(FixedTInfo->getType()); >> > +NewVD->setType(FixedT); >> > NewVD->setTypeSourceInfo(FixedTInfo); >> > } >> > >> > >> > Modified: cfe/trunk/lib/Sema/SemaType.cpp >> > URL:
Re: r332286 - PR37450: Fix bug that disabled some type checks for variables with deduced types.
Sorry for the delay, looking now. On 15 May 2018 at 02:24, Maxim Kuvyrkovwrote: > Hi Richard, > > The for-range-examples.cpp test fails on 32-bit arm buildbots, e.g.: > http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/840 . > Would you please investigate? > > You didn't get a notification because your commit was around the same time > as a fix for an unrelated testcase issue that caused same bots to be red. > > -- > Maxim Kuvyrkov > www.linaro.org > > > > > On May 14, 2018, at 11:15 PM, Richard Smith via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > > > > Author: rsmith > > Date: Mon May 14 13:15:04 2018 > > New Revision: 332286 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=332286=rev > > Log: > > PR37450: Fix bug that disabled some type checks for variables with > deduced types. > > > > Also improve diagnostic for the case where a type is non-literal because > it's a lambda. > > > > Modified: > >cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > >cfe/trunk/lib/Sema/SemaDecl.cpp > >cfe/trunk/lib/Sema/SemaType.cpp > >cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp > >cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp > >cfe/trunk/test/SemaCXX/for-range-examples.cpp > > > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ > DiagnosticSemaKinds.td?rev=332286=332285=332286=diff > > > == > > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May 14 > 13:15:04 2018 > > @@ -2381,6 +2381,8 @@ def note_non_literal_user_provided_dtor > > "%0 is not literal because it has a user-provided destructor">; > > def note_non_literal_nontrivial_dtor : Note< > > "%0 is not literal because it has a non-trivial destructor">; > > +def note_non_literal_lambda : Note< > > + "lambda closure types are non-literal types before C++17">; > > def warn_private_extern : Warning< > > "use of __private_extern__ on a declaration may not produce external > symbol " > > "private to the linkage unit and is deprecated">, > InGroup; > > > > Modified: cfe/trunk/lib/Sema/SemaDecl.cpp > > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ > SemaDecl.cpp?rev=332286=332285=332286=diff > > > == > > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) > > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May 14 13:15:04 2018 > > @@ -7293,8 +7293,7 @@ void Sema::CheckVariableDeclarationType( > > if (NewVD->isInvalidDecl()) > > return; > > > > - TypeSourceInfo *TInfo = NewVD->getTypeSourceInfo(); > > - QualType T = TInfo->getType(); > > + QualType T = NewVD->getType(); > > > > // Defer checking an 'auto' type until its initializer is attached. > > if (T->isUndeducedType()) > > @@ -7438,10 +7437,18 @@ void Sema::CheckVariableDeclarationType( > > (T->isVariableArrayType() && NewVD->hasGlobalStorage())) { > > bool SizeIsNegative; > > llvm::APSInt Oversized; > > -TypeSourceInfo *FixedTInfo = > > - TryToFixInvalidVariablyModifiedTypeSourceInfo(TInfo, Context, > > -SizeIsNegative, > Oversized); > > -if (!FixedTInfo && T->isVariableArrayType()) { > > +TypeSourceInfo *FixedTInfo = TryToFixInvalidVariablyModifie > dTypeSourceInfo( > > +NewVD->getTypeSourceInfo(), Context, SizeIsNegative, Oversized); > > +QualType FixedT; > > +if (FixedTInfo && T == NewVD->getTypeSourceInfo()->getType()) > > + FixedT = FixedTInfo->getType(); > > +else if (FixedTInfo) { > > + // Type and type-as-written are canonically different. We need to > fix up > > + // both types separately. > > + FixedT = TryToFixInvalidVariablyModifiedType(T, Context, > SizeIsNegative, > > + Oversized); > > +} > > +if ((!FixedTInfo || FixedT.isNull()) && T->isVariableArrayType()) { > > const VariableArrayType *VAT = Context.getAsVariableArrayType(T); > > // FIXME: This won't give the correct result for > > // int a[10][n]; > > @@ -7470,7 +7477,7 @@ void Sema::CheckVariableDeclarationType( > > } > > > > Diag(NewVD->getLocation(), diag::warn_illegal_constant_array_size); > > -NewVD->setType(FixedTInfo->getType()); > > +NewVD->setType(FixedT); > > NewVD->setTypeSourceInfo(FixedTInfo); > > } > > > > > > Modified: cfe/trunk/lib/Sema/SemaType.cpp > > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ > SemaType.cpp?rev=332286=332285=332286=diff > > > == > > --- cfe/trunk/lib/Sema/SemaType.cpp (original) > > +++ cfe/trunk/lib/Sema/SemaType.cpp Mon May 14 13:15:04 2018 > > @@
Re: r332286 - PR37450: Fix bug that disabled some type checks for variables with deduced types.
Hi Richard, The for-range-examples.cpp test fails on 32-bit arm buildbots, e.g.: http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/840 . Would you please investigate? You didn't get a notification because your commit was around the same time as a fix for an unrelated testcase issue that caused same bots to be red. -- Maxim Kuvyrkov www.linaro.org > On May 14, 2018, at 11:15 PM, Richard Smith via cfe-commits >wrote: > > Author: rsmith > Date: Mon May 14 13:15:04 2018 > New Revision: 332286 > > URL: http://llvm.org/viewvc/llvm-project?rev=332286=rev > Log: > PR37450: Fix bug that disabled some type checks for variables with deduced > types. > > Also improve diagnostic for the case where a type is non-literal because it's > a lambda. > > Modified: >cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >cfe/trunk/lib/Sema/SemaDecl.cpp >cfe/trunk/lib/Sema/SemaType.cpp >cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp >cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp >cfe/trunk/test/SemaCXX/for-range-examples.cpp > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=332286=332285=332286=diff > == > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May 14 13:15:04 > 2018 > @@ -2381,6 +2381,8 @@ def note_non_literal_user_provided_dtor > "%0 is not literal because it has a user-provided destructor">; > def note_non_literal_nontrivial_dtor : Note< > "%0 is not literal because it has a non-trivial destructor">; > +def note_non_literal_lambda : Note< > + "lambda closure types are non-literal types before C++17">; > def warn_private_extern : Warning< > "use of __private_extern__ on a declaration may not produce external symbol > " > "private to the linkage unit and is deprecated">, InGroup; > > Modified: cfe/trunk/lib/Sema/SemaDecl.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=332286=332285=332286=diff > == > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May 14 13:15:04 2018 > @@ -7293,8 +7293,7 @@ void Sema::CheckVariableDeclarationType( > if (NewVD->isInvalidDecl()) > return; > > - TypeSourceInfo *TInfo = NewVD->getTypeSourceInfo(); > - QualType T = TInfo->getType(); > + QualType T = NewVD->getType(); > > // Defer checking an 'auto' type until its initializer is attached. > if (T->isUndeducedType()) > @@ -7438,10 +7437,18 @@ void Sema::CheckVariableDeclarationType( > (T->isVariableArrayType() && NewVD->hasGlobalStorage())) { > bool SizeIsNegative; > llvm::APSInt Oversized; > -TypeSourceInfo *FixedTInfo = > - TryToFixInvalidVariablyModifiedTypeSourceInfo(TInfo, Context, > -SizeIsNegative, > Oversized); > -if (!FixedTInfo && T->isVariableArrayType()) { > +TypeSourceInfo *FixedTInfo = > TryToFixInvalidVariablyModifiedTypeSourceInfo( > +NewVD->getTypeSourceInfo(), Context, SizeIsNegative, Oversized); > +QualType FixedT; > +if (FixedTInfo && T == NewVD->getTypeSourceInfo()->getType()) > + FixedT = FixedTInfo->getType(); > +else if (FixedTInfo) { > + // Type and type-as-written are canonically different. We need to fix > up > + // both types separately. > + FixedT = TryToFixInvalidVariablyModifiedType(T, Context, > SizeIsNegative, > + Oversized); > +} > +if ((!FixedTInfo || FixedT.isNull()) && T->isVariableArrayType()) { > const VariableArrayType *VAT = Context.getAsVariableArrayType(T); > // FIXME: This won't give the correct result for > // int a[10][n]; > @@ -7470,7 +7477,7 @@ void Sema::CheckVariableDeclarationType( > } > > Diag(NewVD->getLocation(), diag::warn_illegal_constant_array_size); > -NewVD->setType(FixedTInfo->getType()); > +NewVD->setType(FixedT); > NewVD->setTypeSourceInfo(FixedTInfo); > } > > > Modified: cfe/trunk/lib/Sema/SemaType.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=332286=332285=332286=diff > == > --- cfe/trunk/lib/Sema/SemaType.cpp (original) > +++ cfe/trunk/lib/Sema/SemaType.cpp Mon May 14 13:15:04 2018 > @@ -7809,6 +7809,13 @@ bool Sema::RequireLiteralType(SourceLoca > if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, > T)) > return true; > > + // [expr.prim.lambda]p3: > + // This class type is [not] a literal type. > + if (RD->isLambda() && !getLangOpts().CPlusPlus17) {
r332286 - PR37450: Fix bug that disabled some type checks for variables with deduced types.
Author: rsmith Date: Mon May 14 13:15:04 2018 New Revision: 332286 URL: http://llvm.org/viewvc/llvm-project?rev=332286=rev Log: PR37450: Fix bug that disabled some type checks for variables with deduced types. Also improve diagnostic for the case where a type is non-literal because it's a lambda. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp cfe/trunk/test/SemaCXX/for-range-examples.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=332286=332285=332286=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May 14 13:15:04 2018 @@ -2381,6 +2381,8 @@ def note_non_literal_user_provided_dtor "%0 is not literal because it has a user-provided destructor">; def note_non_literal_nontrivial_dtor : Note< "%0 is not literal because it has a non-trivial destructor">; +def note_non_literal_lambda : Note< + "lambda closure types are non-literal types before C++17">; def warn_private_extern : Warning< "use of __private_extern__ on a declaration may not produce external symbol " "private to the linkage unit and is deprecated">, InGroup; Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=332286=332285=332286=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May 14 13:15:04 2018 @@ -7293,8 +7293,7 @@ void Sema::CheckVariableDeclarationType( if (NewVD->isInvalidDecl()) return; - TypeSourceInfo *TInfo = NewVD->getTypeSourceInfo(); - QualType T = TInfo->getType(); + QualType T = NewVD->getType(); // Defer checking an 'auto' type until its initializer is attached. if (T->isUndeducedType()) @@ -7438,10 +7437,18 @@ void Sema::CheckVariableDeclarationType( (T->isVariableArrayType() && NewVD->hasGlobalStorage())) { bool SizeIsNegative; llvm::APSInt Oversized; -TypeSourceInfo *FixedTInfo = - TryToFixInvalidVariablyModifiedTypeSourceInfo(TInfo, Context, -SizeIsNegative, Oversized); -if (!FixedTInfo && T->isVariableArrayType()) { +TypeSourceInfo *FixedTInfo = TryToFixInvalidVariablyModifiedTypeSourceInfo( +NewVD->getTypeSourceInfo(), Context, SizeIsNegative, Oversized); +QualType FixedT; +if (FixedTInfo && T == NewVD->getTypeSourceInfo()->getType()) + FixedT = FixedTInfo->getType(); +else if (FixedTInfo) { + // Type and type-as-written are canonically different. We need to fix up + // both types separately. + FixedT = TryToFixInvalidVariablyModifiedType(T, Context, SizeIsNegative, + Oversized); +} +if ((!FixedTInfo || FixedT.isNull()) && T->isVariableArrayType()) { const VariableArrayType *VAT = Context.getAsVariableArrayType(T); // FIXME: This won't give the correct result for // int a[10][n]; @@ -7470,7 +7477,7 @@ void Sema::CheckVariableDeclarationType( } Diag(NewVD->getLocation(), diag::warn_illegal_constant_array_size); -NewVD->setType(FixedTInfo->getType()); +NewVD->setType(FixedT); NewVD->setTypeSourceInfo(FixedTInfo); } Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=332286=332285=332286=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Mon May 14 13:15:04 2018 @@ -7809,6 +7809,13 @@ bool Sema::RequireLiteralType(SourceLoca if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, T)) return true; + // [expr.prim.lambda]p3: + // This class type is [not] a literal type. + if (RD->isLambda() && !getLangOpts().CPlusPlus17) { +Diag(RD->getLocation(), diag::note_non_literal_lambda); +return true; + } + // If the class has virtual base classes, then it's not an aggregate, and // cannot have any constexpr constructors or a trivial default constructor, // so is non-literal. This is better to diagnose than the resulting absence Modified: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp?rev=332286=332285=332286=diff == --- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp