[cfe-commits] [PATCH] for bug 7970 and another member declaration bug found along the way

Faisal Vali faisalv at yahoo.com
Fri Aug 27 16:47:33 PDT 2010


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prevent-static-var-in-class-redeclaration-2.patch
Type: application/octet-stream
Size: 5508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100827/d5b68990/attachment.obj>


More information about the cfe-commits mailing list