On 02/17/15 21:35, Richard Smith wrote:
Sorry for the delay. The patch looks good, other than some style issues:
No spaces before ().
Damn, I checked so carefully ...
Please add braces around this 'if', since its body contains many lines.
done
test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp
I'm not really sure what part of p9 this is testing; it seems more to be a test
of p4, where inheritance of default arguments is specified.
Ah, I'd not understood the naming convention here. I've moved that code into
p4.cpp.
tested on x86_64-linux, ok?
nathan
Index: src/tools/clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- src/tools/clang/lib/Sema/SemaDeclCXX.cpp (revision 229679)
+++ src/tools/clang/lib/Sema/SemaDeclCXX.cpp (working copy)
@@ -521,7 +521,9 @@ bool Sema::MergeCXXFunctionDecl(Function
// It's important to use getInit() here; getDefaultArg()
// strips off any top-level ExprWithCleanups.
NewParam->setHasInheritedDefaultArg();
- if (OldParam->hasUninstantiatedDefaultArg())
+ if (OldParam->hasUnparsedDefaultArg())
+ NewParam->setUnparsedDefaultArg();
+ else if (OldParam->hasUninstantiatedDefaultArg())
NewParam->setUninstantiatedDefaultArg(
OldParam->getUninstantiatedDefaultArg());
else
Index: src/tools/clang/lib/Parse/ParseDeclCXX.cpp
===================================================================
--- src/tools/clang/lib/Parse/ParseDeclCXX.cpp (revision 229679)
+++ src/tools/clang/lib/Parse/ParseDeclCXX.cpp (working copy)
@@ -1896,13 +1896,16 @@ void Parser::HandleMemberFunctionDeclDel
// late parse
bool NeedLateParse = FTI.getExceptionSpecType() == EST_Unparsed;
- if (!NeedLateParse)
+ if (!NeedLateParse) {
// Look ahead to see if there are any default args
- for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx)
- if (FTI.Params[ParamIdx].DefaultArgTokens) {
+ for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx) {
+ auto Param = cast<ParmVarDecl>(FTI.Params[ParamIdx].Param);
+ if (Param->hasUnparsedDefaultArg()) {
NeedLateParse = true;
break;
}
+ }
+ }
if (NeedLateParse) {
// Push this method onto the stack of late-parsed method
Index: src/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp
===================================================================
--- src/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp (revision 229679)
+++ src/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp (working copy)
@@ -306,8 +306,9 @@ void Parser::ParseLexedMethodDeclaration
ParseScope PrototypeScope(this, Scope::FunctionPrototypeScope |
Scope::FunctionDeclarationScope | Scope::DeclScope);
for (unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
- auto Param = LM.DefaultArgs[I].Param;
+ auto Param = cast<ParmVarDecl>(LM.DefaultArgs[I].Param);
// Introduce the parameter into scope.
+ bool HasUnparsed = Param->hasUnparsedDefaultArg();
Actions.ActOnDelayedCXXMethodParameter(getCurScope(), Param);
if (CachedTokens *Toks = LM.DefaultArgs[I].Toks) {
// Mark the end of the default argument so that we know when to stop when
@@ -371,6 +372,16 @@ void Parser::ParseLexedMethodDeclaration
delete Toks;
LM.DefaultArgs[I].Toks = nullptr;
+ } else if (HasUnparsed) {
+ assert(Param->hasInheritedDefaultArg());
+ FunctionDecl *Old = cast<FunctionDecl>(LM.Method)->getPreviousDecl();
+ ParmVarDecl *OldParam = Old->getParamDecl(I);
+ assert (!OldParam->hasUnparsedDefaultArg());
+ if (OldParam->hasUninstantiatedDefaultArg())
+ Param->setUninstantiatedDefaultArg(
+ Param->getUninstantiatedDefaultArg());
+ else
+ Param->setDefaultArg(OldParam->getInit());
}
}
Index: src/tools/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
===================================================================
--- src/tools/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp (revision 229679)
+++ src/tools/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp (working copy)
@@ -54,3 +54,22 @@ namespace N1 {
f2(6); // okay
}
}
+
+
+namespace PR18432 {
+
+struct A {
+ struct B {
+ static void Foo (int = 0);
+ };
+
+ // should not hide default args
+ friend void B::Foo (int);
+};
+
+void Test ()
+{
+ A::B::Foo ();
+}
+
+} // namespace
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits