diff options
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 7 | ||||
-rw-r--r-- | test/SemaCXX/default2.cpp | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index f5681af0fa..c0160b2d42 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1707,8 +1707,11 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, ProcessDeclAttributes(NewFD, D); if (getLangOptions().CPlusPlus) { - // In C++, check default arguments now that we have merged decls. - CheckCXXDefaultArguments(NewFD); + // In C++, check default arguments now that we have merged decls. Unless + // the lexical context is the class, because in this case this is done + // during delayed parsing anyway. + if (!CurContext->isRecord()) + CheckCXXDefaultArguments(NewFD); // An out-of-line member function declaration must also be a // definition (C++ [dcl.meaning]p1). diff --git a/test/SemaCXX/default2.cpp b/test/SemaCXX/default2.cpp index 604354b9af..f3d726fbee 100644 --- a/test/SemaCXX/default2.cpp +++ b/test/SemaCXX/default2.cpp @@ -1,6 +1,4 @@ // RUN: clang -fsyntax-only -verify %s -// XFAIL -// fails due to exact diagnostic matching void f(int i, int j, int k = 3); void f(int i, int j, int k); @@ -100,7 +98,7 @@ int Y::mem4(int i = a) // expected-error{{invalid use of nonstatic data member ' // constructors. class Z { public: - Z(Z&, int i = 17); // expected-note{{candidate function}} + Z(Z&, int i = 17); // expected-note 2 {{candidate function}} void f(Z& z) { Z z2; // expected-error{{no matching constructor for initialization}} |