From 208732e9545bf4b50095d4c9a7836512c366853c Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 8 Dec 2016 03:24:55 +0000 Subject: [PATCH] [c++1z] P0490R0, NB comment GB 20: if std::tuple_size is complete, use the tuple-like interpretation of decomposition declaration even if there is no ::value member. We already did this, anticipating this resolution, just update comments and tweak a testcase. llvm-svn: 289021 --- clang/lib/Sema/SemaDeclCXX.cpp | 7 ++----- clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index ed77a42..fd33b31 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -983,11 +983,8 @@ static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T, if (lookupStdTypeTraitMember(S, R, Loc, "tuple_size", Args, /*DiagID*/0)) return IsTupleLike::NotTupleLike; - // FIXME: According to the standard, we're not supposed to diagnose if any - // of the steps below fail (or if lookup for ::value is ambiguous or otherwise - // results in an error), but this is subject to a pending CWG issue / NB - // comment, which says we do diagnose if tuple_size is complete but - // tuple_size::value is not an ICE. + // If we get this far, we've committed to the tuple interpretation, but + // we can still fail if there actually isn't a usable ::value. struct ICEDiagnoser : Sema::VerifyICEDiagnoser { LookupResult &R; diff --git a/clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp b/clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp index e4a7a6c..b7092e3 100644 --- a/clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp +++ b/clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp @@ -10,7 +10,7 @@ void no_tuple_size_1() { auto [x, y] = A(); } // ok, decompose elementwise namespace std { template struct tuple_size; } void no_tuple_size_2() { auto [x, y] = A(); } // ok, decompose elementwise -struct Bad1 {}; +struct Bad1 { int a, b; }; template<> struct std::tuple_size {}; void no_tuple_size_3() { auto [x, y] = Bad1(); } // expected-error {{cannot decompose this type; 'std::tuple_size::value' is not a valid integral constant expression}} -- 2.7.4