c++: check completeness after auto deduction [PR80351]
Normally we check for incomplete type in start_decl, but that obviously doesn't work for auto variables. Thanks to Pokechu22 for the analysis and testcases: "When cp_finish_decl calls cp_apply_type_quals_to_decl on a const auto or constexpr auto variable, the type might not be complete the first time (this happened when auto deduces to an initializer_list). cp_apply_type_quals_to_decl removes the const qualifier if the type is not complete, which is appropriate for grokdeclarator, on the assumption that the type will be complete when called by cp_finish_decl." PR c++/80351 gcc/cp/ChangeLog: * decl.cc (cp_finish_decl): Check completeness of deduced type. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-77482.C: Adjust message. * g++.dg/cpp1y/auto-fn27.C: Likewise. * g++.dg/cpp1y/lambda-generic-variadic22.C: Likewise. * g++.dg/cpp1z/decomp54.C: Likewise. * g++.dg/cpp0x/initlist-const1.C: New test. * g++.dg/warn/Wunused-var-37.C: New test. * g++.dg/warn/Wunused-var-38.C: New test. * g++.dg/warn/Wunused-var-39.C: New test.
Showing
- gcc/cp/decl.cc 11 additions, 0 deletionsgcc/cp/decl.cc
- gcc/testsuite/g++.dg/cpp0x/constexpr-77482.C 1 addition, 1 deletiongcc/testsuite/g++.dg/cpp0x/constexpr-77482.C
- gcc/testsuite/g++.dg/cpp0x/initlist-const1.C 7 additions, 0 deletionsgcc/testsuite/g++.dg/cpp0x/initlist-const1.C
- gcc/testsuite/g++.dg/cpp1y/auto-fn27.C 1 addition, 1 deletiongcc/testsuite/g++.dg/cpp1y/auto-fn27.C
- gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic22.C 1 addition, 1 deletiongcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic22.C
- gcc/testsuite/g++.dg/cpp1z/decomp54.C 2 additions, 2 deletionsgcc/testsuite/g++.dg/cpp1z/decomp54.C
- gcc/testsuite/g++.dg/warn/Wunused-var-37.C 64 additions, 0 deletionsgcc/testsuite/g++.dg/warn/Wunused-var-37.C
- gcc/testsuite/g++.dg/warn/Wunused-var-38.C 16 additions, 0 deletionsgcc/testsuite/g++.dg/warn/Wunused-var-38.C
- gcc/testsuite/g++.dg/warn/Wunused-var-39.C 16 additions, 0 deletionsgcc/testsuite/g++.dg/warn/Wunused-var-39.C
Loading
Please register or sign in to comment