зеркало из https://github.com/microsoft/clang-1.git
Merge uninstantiated default arguments more carefully, and try not to
complain about specializations of member functions that are not definitions. Fixes PR4995. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82159 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
2bd6b9f298
Коммит
d85cef5a54
|
@ -2684,7 +2684,9 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
|||
if (D.getCXXScopeSpec().isSet() && !NewFD->isInvalidDecl()) {
|
||||
// An out-of-line member function declaration must also be a
|
||||
// definition (C++ [dcl.meaning]p1).
|
||||
if (!IsFunctionDefinition && !isFriend) {
|
||||
// FIXME: Find a better way to recognize out-of-line specializations!
|
||||
if (!IsFunctionDefinition && !isFriend &&
|
||||
!(TemplateParamLists.size() && !FunctionTemplate)) {
|
||||
Diag(NewFD->getLocation(), diag::err_out_of_line_declaration)
|
||||
<< D.getCXXScopeSpec().getRange();
|
||||
NewFD->setInvalidDecl();
|
||||
|
|
|
@ -280,9 +280,13 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old) {
|
|||
Diag(OldParam->getLocation(), diag::note_previous_definition)
|
||||
<< OldParam->getDefaultArgRange();
|
||||
Invalid = true;
|
||||
} else if (OldParam->getDefaultArg()) {
|
||||
} else if (OldParam->hasDefaultArg()) {
|
||||
// Merge the old default argument into the new parameter
|
||||
NewParam->setDefaultArg(OldParam->getDefaultArg());
|
||||
if (OldParam->hasUninstantiatedDefaultArg())
|
||||
NewParam->setUninstantiatedDefaultArg(
|
||||
OldParam->getUninstantiatedDefaultArg());
|
||||
else
|
||||
NewParam->setDefaultArg(OldParam->getDefaultArg());
|
||||
} else if (NewParam->hasDefaultArg()) {
|
||||
if (New->getDescribedFunctionTemplate()) {
|
||||
// Paragraph 4, quoted above, only applies to non-template functions.
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
// RUN: clang-cc -fsyntax-only -verify %s
|
||||
|
||||
template<typename T>
|
||||
class C { C(int a0 = 0); };
|
||||
|
||||
template<>
|
||||
C<char>::C(int a0);
|
||||
|
||||
struct S { };
|
||||
|
||||
template<typename T> void f1(T a, T b = 10) { } // expected-error{{cannot initialize 'b' with an rvalue of type 'int'}}
|
||||
|
|
Загрузка…
Ссылка в новой задаче