[clang] add diagnose when member function contains invalid default argument
Fixed: https://github.com/llvm/llvm-project/issues/62122 This change pointer to add diagnose message for this code. ``` struct S { static int F(int n = 0 ? 0) { return 0; } }; ``` For default parameter, we should set it as unparsed even if meeting syntax error because it should be issued in real parser time instead of set is as invalid directly without diagnose. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D148372
This commit is contained in:
parent
f34ecb50e2
commit
3333e12753
@ -321,6 +321,8 @@ Bug Fixes in This Version
|
|||||||
(`#61885 <https://github.com/llvm/llvm-project/issues/61885>`_)
|
(`#61885 <https://github.com/llvm/llvm-project/issues/61885>`_)
|
||||||
- Clang constexpr evaluator now treats comparison of [[gnu::weak]]-attributed
|
- Clang constexpr evaluator now treats comparison of [[gnu::weak]]-attributed
|
||||||
member pointer as an invalid expression.
|
member pointer as an invalid expression.
|
||||||
|
- Fix crash when member function contains invalid default argument.
|
||||||
|
(`#62122 <https://github.com/llvm/llvm-project/issues/62122>`_)
|
||||||
|
|
||||||
Bug Fixes to Compiler Builtins
|
Bug Fixes to Compiler Builtins
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -7381,13 +7381,9 @@ void Parser::ParseParameterDeclarationClause(
|
|||||||
DefArgToks.reset(new CachedTokens);
|
DefArgToks.reset(new CachedTokens);
|
||||||
|
|
||||||
SourceLocation ArgStartLoc = NextToken().getLocation();
|
SourceLocation ArgStartLoc = NextToken().getLocation();
|
||||||
if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
|
ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument);
|
||||||
DefArgToks.reset();
|
|
||||||
Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
|
|
||||||
} else {
|
|
||||||
Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
|
Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
|
||||||
ArgStartLoc);
|
ArgStartLoc);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Consume the '='.
|
// Consume the '='.
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
|
@ -108,4 +108,9 @@ class G {
|
|||||||
// expected-error@-2 {{type name requires a specifier or qualifier}}
|
// expected-error@-2 {{type name requires a specifier or qualifier}}
|
||||||
// expected-error@-3 {{expected '>'}}
|
// expected-error@-3 {{expected '>'}}
|
||||||
// expected-note@-4 {{to match this '<'}}
|
// expected-note@-4 {{to match this '<'}}
|
||||||
|
|
||||||
|
void n(int x = 1 ? 2) {}
|
||||||
|
// expected-error@-1 {{expected ':'}}
|
||||||
|
// expected-note@-2 {{to match this '?'}}
|
||||||
|
// expected-error@-3 {{expected expression}}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user