[Clang][Sema] Prohibit statement expression in the default argument
authorJun Zhang <jun@junz.org>
Wed, 6 Apr 2022 00:45:46 +0000 (08:45 +0800)
committerJun Zhang <jun@junz.org>
Wed, 6 Apr 2022 01:28:20 +0000 (09:28 +0800)
commit8a4d388c7fa47fa50076babecc38757009dbc987
tree5f17bbda81f6b04889f3b1011f21304279cbf4e5
parentc32f8f34614d89dbe4978b71b6e2a6da17b1b0d4
[Clang][Sema] Prohibit statement expression in the default argument

As statement expression makes no sense in the default argument,
this patch tries to disable it in the all cases.

Please note that the statement expression is a GNU extension, which
means that Clang should be consistent with GCC. However, there's no
response from GCC devs since we have raised the issue for several weeks.
In this case, I think we can disallow statement expressions as a default
parameter in general for now, and relax the restriction if GCC folks
decide to retain the feature for functions but not lambdas in the
future.

Related discussion: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104765

Fixes https://github.com/llvm/llvm-project/issues/53488

Differential Revision: https://reviews.llvm.org/D119609
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseTemplate.cpp
clang/test/Sema/stmt-expr-in-default-arg.cpp [new file with mode: 0644]
clang/test/SemaTemplate/dependent-expr.cpp