[cfe-commits] [PATCH] Allow redeclaring a function in an inner scope with different default arguments

James Molloy james.molloy at arm.com
Fri Mar 9 04:02:09 PST 2012


The following code is legal according to the c++ standard:

void f() {
  int g(int a, int b=4);
    int g(int a, int b=5);

Because "[snip] That is, declarations in inner scopes do not acquire default
arguments from declarations in outer scopes, and vice versa."

Clang currently quotes this part of the standard in a comment, but does not
adhere to it. The attached patch fixes this so the above code compiles
without errors.

This involves passing information about whether the new and old declarations
are in the same Scope when merging them.

Please review! :)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: cxx-inner-scope-default-args.diff
Type: application/octet-stream
Size: 6483 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120309/21303bdc/attachment.obj>

More information about the cfe-commits mailing list