Thanks. We have some code in SemaDecl(CXX?) that was trying to do the same thing; can it be removed now?
On 11 Nov 2016 1:00 pm, "Richard Trieu via cfe-commits" < cfe-commits@lists.llvm.org> wrote: > Author: rtrieu > Date: Fri Nov 11 14:51:04 2016 > New Revision: 286630 > > URL: http://llvm.org/viewvc/llvm-project?rev=286630&view=rev > Log: > When a DecompositionDecl is marked invalid, also set the child > BindingDecl's to > invalid. > > Modified: > cfe/trunk/lib/AST/DeclBase.cpp > cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp > > Modified: cfe/trunk/lib/AST/DeclBase.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ > DeclBase.cpp?rev=286630&r1=286629&r2=286630&view=diff > ============================================================ > ================== > --- cfe/trunk/lib/AST/DeclBase.cpp (original) > +++ cfe/trunk/lib/AST/DeclBase.cpp Fri Nov 11 14:51:04 2016 > @@ -109,12 +109,24 @@ const char *Decl::getDeclKindName() cons > void Decl::setInvalidDecl(bool Invalid) { > InvalidDecl = Invalid; > assert(!isa<TagDecl>(this) || !cast<TagDecl>(this)-> > isCompleteDefinition()); > - if (Invalid && !isa<ParmVarDecl>(this)) { > + if (!Invalid) { > + return; > + } > + > + if (!isa<ParmVarDecl>(this)) { > // Defensive maneuver for ill-formed code: we're likely not to make > it to > // a point where we set the access specifier, so default it to > "public" > // to avoid triggering asserts elsewhere in the front end. > setAccess(AS_public); > } > + > + // Marking a DecompositionDecl as invalid implies all the child > BindingDecl's > + // are invalid too. > + if (DecompositionDecl *DD = dyn_cast<DecompositionDecl>(this)) { > + for (BindingDecl *Binding : DD->bindings()) { > + Binding->setInvalidDecl(); > + } > + } > } > > const char *DeclContext::getDeclKindName() const { > > Modified: cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ > SemaCXX/cxx1z-decomposition.cpp?rev=286630&r1=286629&r2=286630&view=diff > ============================================================ > ================== > --- cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp (original) > +++ cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp Fri Nov 11 14:51:04 > 2016 > @@ -53,4 +53,16 @@ void bitfield() { > auto &[p, q, r] = a; // expected-error {{decomposes into 2 elements, > but 3 names were provided}} > } > > +void for_range() { > + int x = 1; > + for (auto[a, b] : x) { // expected-error {{invalid range expression of > type 'int'; no viable 'begin' function available}} > + a++; > + } > + > + int y[5]; > + for (auto[c] : y) { // expected-error {{cannot decompose non-class, > non-array type 'int'}} > + c++; > + } > +} > + > // FIXME: by-value array copies > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits