This is an updated patch which spits out more consistent sounding error messages. In Sema::MergeVarDecl, instead of doing (pseudo code) if (LR.isSingleResult()) PDecl = LR.getFoundDecl() I used: if (!LR.empty()) PDecl = LR.getRepresentativeDecl()
Thanks! Faisal Vali On Fri, Aug 27, 2010 at 6:47 PM, Faisal Vali <[email protected]> wrote: > Hi, > > This patch fixes the following bugs: > - redeclaration of in class static variables (http://llvm.org/PR7970) > - redeclaration of an in class non-static variable was allowed if > *two* or more overloaded functions with that same name had already > been declared > i.e. struct S { void f(); int f(int); char f; }; would compile > because Sema::LookupSingleResult in Sema::HandleField would return > null > if LookupResult was an overloaded result. > > I have attached a bunch of tests in p1 (not sure if they are all > necessary), and if you review the test file, you'll see that depending > on the ordering of member declarations > (i.e data before functions or static before non-static) different > error messages are spit out. Something smells quite brittle about > this. I wonder if it > would be worthwhile to try and unify these member declaration checks > in one place and then call them consistently from HandleField, > HandleDeclarator and MergeVarDecl, > or would this complicate more than simplify? > > I verified my changes against the tests in SemaCXX and CXX. > > I am quite new at this so would appreciate any constructive feedback :) > > thanks, > Faisal Vali >
prevent-static-var-in-class-redeclaration-3.patch
Description: Binary data
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
