[cfe-dev] Modules, redeclaration chains, and locally-scoped extern declarations

Jordan Rose via cfe-dev cfe-dev at lists.llvm.org
Thu Sep 26 14:38:10 PDT 2019


Hi, modules folks and cfe-dev. I think I've discovered a bug in how module loading handles redeclaration merging, but it might also be by design. (And honestly "by design" would be nice in my particular use case.) Here it is:

// ModuleA.h
void test() {
  extern void sharedFunc(void);
}

// ModuleB.h
void sharedFunc(int);

// client.c
#import <ModuleA.h>
#import <ModuleB.h>
// or the other order, for a slightly different experiment

In this situation, the locally-scoped declaration of 'sharedFunc' in ModuleA isn't resolved with the declaration in ModuleB. There's even a conflict in their types! Is this by design, or an oversight, or what?

One of the consequences of this is that in client.c's context, asking for the canonical decl for 'sharedFunc' gives me the declaration in ModuleB. From client.c's perspective, that's more useful than giving me the one in ModuleA, but it's not consistent with the behavior with modules turned off.

Any insights to offer? Should I file this at bugs.llvm.org?
Thanks,
Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190926/c68203b0/attachment.html>


More information about the cfe-dev mailing list