[cfe-commits] [PATCH] Fix tag decls/enum constants in function prototypes

James Molloy james.molloy at arm.com
Wed Jan 18 07:56:24 PST 2012


Hi,

Attached is a patch that fixes PR5477 and PR5464
(http://llvm.org/bugs/show_bug.cgi?id=5477 ,
http://llvm.org/bugs/show_bug.cgi?id=5464).

The problem is ensuring tags and enum constants that are created as part of
a function prototype end up in the scope of the function definition, and
ensuring that they do not incorrectly conflict with identifiers in the
global scope. E.g.:

Const int AA = 5;
int f (enum {AA, BB} e) {
  Return AA;
}

Clang currently errors out: test.c:2:15: error: redefinition of 'AA'

The patch attached fixes this, and more complex examples such as:

struct a {
    struct b {
        int j;
    } b;
};

int foo(struct a { struct b { int j; } b; struct b { char glorx; } glorx; }
*);

It introduces some statefulness into Sema, but it appears that Sema is
already stateful so I hope that won't be a problem.

Could someone please review it? (some code taken from the current patch at
PR5464)

Cheers,

James
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: enum_prototypes.diff
Type: application/octet-stream
Size: 13289 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120118/7542f9b8/attachment.obj>


More information about the cfe-commits mailing list