r289021 - [c++1z] P0490R0, NB comment GB 20: if std::tuple_size<T> is complete, use the

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 7 19:24:55 PST 2016


Author: rsmith
Date: Wed Dec  7 21:24:55 2016
New Revision: 289021

URL: http://llvm.org/viewvc/llvm-project?rev=289021&view=rev
Log:
[c++1z] P0490R0, NB comment GB 20: if std::tuple_size<T> 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.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p3.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=289021&r1=289020&r2=289021&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Dec  7 21:24:55 2016
@@ -983,11 +983,8 @@ static IsTupleLike isTupleLike(Sema &S,
   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<T> is complete but
-  // tuple_size<T>::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;

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p3.cpp?rev=289021&r1=289020&r2=289021&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p3.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p3.cpp Wed Dec  7 21:24:55 2016
@@ -10,7 +10,7 @@ void no_tuple_size_1() { auto [x, y] = A
 namespace std { template<typename T> 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<Bad1> {};
 void no_tuple_size_3() { auto [x, y] = Bad1(); } // expected-error {{cannot decompose this type; 'std::tuple_size<Bad1>::value' is not a valid integral constant expression}}
 




More information about the cfe-commits mailing list