llvm-project/clang/test/SemaTemplate
Jun Zhang 8a4d388c7f
[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
2022-04-06 09:28:20 +08:00
..
ackermann.cpp
address-spaces.cpp
address_space-dependent.cpp [SYCL] Enable `opencl_global_[host,device]` attributes for SYCL 2021-05-18 10:27:35 +03:00
alias-church-numerals.cpp
alias-nested-nontag.cpp
alias-template-nondependent.cpp PR46377: Fix dependence calculation for function types and typedef 2020-07-28 13:23:13 -07:00
alias-template-template-param.cpp
alias-templates.cpp When performing a substitution into a dependent alias template, mark the 2020-06-23 14:43:04 -07:00
alignas.cpp
ambiguous-ovl-print.cpp
anonymous-union.cpp
argument-dependent-lookup.cpp
array-redeclaration.cpp Don't assert if we find a dependently-typed variable in the 2020-06-16 19:41:13 -07:00
array-to-pointer-decay.cpp
atomics.cpp Relax assert in ExprConstant to a return None. 2021-10-21 13:09:56 +01:00
attributes.cpp Allow parameter pack expansions and initializer lists in annotate attribute 2022-02-08 13:38:07 -05:00
canonical-expr-type-0x.cpp
canonical-expr-type.cpp
class-template-ctor-initializer.cpp
class-template-decl.cpp Ensure that we transform types into the current instantiation even if 2020-12-17 23:23:05 -08:00
class-template-id-2.cpp
class-template-id.cpp Print default template argument if manually specified in typedef declaration. 2021-06-29 14:57:26 +00:00
class-template-noexcept.cpp let EST_Uninstantiated in FunctionProtoType::canThrow return 2022-03-16 07:09:42 -07:00
class-template-spec.cpp Suppress printing template arguments that match default template 2020-11-11 15:05:51 -08:00
concepts.cpp [Concepts] Fix placeholder constraints when references are involved 2022-03-23 11:14:58 -04:00
constexpr-instantiate.cpp
constraints.cpp [clang] Correctly(?) handle placeholder types in ExprRequirements. 2022-02-01 15:16:17 -05:00
constructor-template.cpp Consistent spelling in diagnostics: {l,r}value instead of {l,r}-value 2020-11-15 18:05:11 +01:00
copy-ctor-assign.cpp
crash-8204126.cpp
crash-10438657.cpp
crash-unparsed-exception.cpp
crash.cpp
ctad.cpp Treat implicit deduction guides as being equivalent to their 2021-05-19 13:31:53 -07:00
current-instantiation.cpp
cxx1z-decomposition.cpp
cxx1z-fold-expressions.cpp PR30738: Implement two-phase name lookup for fold-expressions. 2020-08-06 16:56:39 -07:00
cxx1z-using-declaration.cpp PR48339: Improve diagnostics for invalid dependent unqualified function calls. 2020-12-02 17:54:55 -08:00
cxx2a-constraint-caching.cpp PR50402: Use proper constant evaluation rules for checking constraint 2021-05-19 16:02:53 -07:00
cxx2a-constraint-exprs.cpp [Concepts] Transform constraints of non-template functions to ConstantEvaluated 2020-01-25 23:00:24 +02:00
cxx17-inline-variables.cpp
deduction-crash.cpp [clang] set templates as invalid when any of the parameters are invalid 2021-09-25 04:04:47 +02:00
deduction-guide.cpp [clang] Propagate requires-clause from constructor template to implicit deduction guide 2022-03-25 02:46:22 -04:00
deduction.cpp [clang] retain type sugar in auto / template argument deduction 2021-11-15 23:07:45 +01:00
default-arguments-ast-print.cpp Print default template argument if manually specified in typedef declaration. 2021-06-29 14:57:26 +00:00
default-arguments-cxx0x.cpp PR46648: Do not eagerly instantiate default arguments for a generic 2020-07-09 17:24:20 -07:00
default-arguments.cpp Revert "[clang] deprecate frelaxed-template-template-args, make it on by default" 2021-11-02 17:02:19 -04:00
default-expr-arguments-2.cpp
default-expr-arguments-3.cpp
default-expr-arguments.cpp
default-member-init.cpp Fix assert on valid due to incorrect assumption that a field name must 2020-11-18 14:04:02 -08:00
defaulted-destructor-in-temporary.cpp [Sema] Mark the referenced destructor during transformation of a `CXXBindTemporaryExpr` 2022-03-08 01:00:07 -08:00
defaulted.cpp Fix rejects-valid when referencing an implicit operator== from within a 2020-06-22 20:19:20 -07:00
delegating-constructors.cpp Add type information to integral template argument if required. 2021-05-12 19:00:08 +00:00
dependent-base-classes.cpp Part of C++ DR 39: a class member lookup is not ambiguous if it finds the 2020-11-25 17:03:11 -08:00
dependent-base-member-init.cpp
dependent-class-member-operator.cpp
dependent-expr.cpp [Clang][Sema] Prohibit statement expression in the default argument 2022-04-06 09:28:20 +08:00
dependent-names-no-std.cpp
dependent-names.cpp PR48339: Improve diagnostics for invalid dependent unqualified function calls. 2020-12-02 17:54:55 -08:00
dependent-sized_array.cpp
dependent-template-recover.cpp
dependent-type-identity.cpp
dependent-typos-recovery.cpp PR48339: Improve diagnostics for invalid dependent unqualified function calls. 2020-12-02 17:54:55 -08:00
derived.cpp Diagnose -Wunused-value based on CFG reachability 2021-09-28 10:00:15 -07:00
destructor-template.cpp [Sema] Fixes a crash with a templated destructor 2019-11-07 21:22:27 +01:00
diagnose-enable-if-t.cpp [clang] Enable the special enable_if_t diagnostics for libc++'s __enable_if_t as well. 2021-09-11 13:44:51 -05:00
elaborated-type-specifier.cpp
enum-argument.cpp Fix type-dependency of bitfields in templates 2020-02-12 13:31:41 -08:00
enum-bool.cpp
enum-forward.cpp
example-typelist.cpp
exception-spec-crash.cpp
explicit-instantiation.cpp Don't instantiate lambda closure types in default member initializers 2020-10-20 17:37:07 -07:00
explicit-specialization-member.cpp
ext-vector-type.cpp
ext_ms_template_spec.cpp
extension-sfinae.cpp
extern-templates.cpp [Sema][C++] Propagate conversion kind to specialize the diagnostics 2020-02-25 16:05:37 +00:00
fibonacci.cpp
find-unexpanded-packs.cpp An expression should only contain an unexpanded parameter pack if it 2022-03-31 20:02:53 -07:00
friend-template.cpp [clang][SemaTemplate] Fix a stack use after scope 2022-02-17 21:47:50 +01:00
friend.cpp [clang] retain type sugar in auto / template argument deduction 2021-11-15 23:07:45 +01:00
fun-template-def.cpp [Sema] Add test for new errors due to 09f8315bba 2022-01-18 22:18:35 +01:00
function-pointer-qualifier.cpp
function-template-specialization-noreturn.cpp
function-template-specialization.cpp
generic-lambda.cpp [clang] don't instantiate templates with injected arguments 2021-09-29 23:19:13 +02:00
implicit-instantiation-1.cpp
inject-templated-friend-post.cpp
inject-templated-friend.cpp
injected-class-name.cpp
instantiate-abbreviated-template.cpp [Concepts] Add null check for TemplateTypeParmType::getDecl() in GetContainedInventedTypeParmVisitor 2020-03-06 19:32:10 +02:00
instantiate-after-fatal-cxx17.cpp
instantiate-anonymous-union.cpp
instantiate-array.cpp
instantiate-attr.cpp [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX 2022-02-01 11:49:53 -05:00
instantiate-c99.cpp [c++20] Implement semantic restrictions for C++20 designated 2019-08-30 22:52:55 +00:00
instantiate-call.cpp
instantiate-case.cpp
instantiate-cast.cpp [Diagnostics] Improve some error messages related to bad use of dynamic_cast 2019-11-04 16:26:43 +01:00
instantiate-clang.cpp
instantiate-complete.cpp
instantiate-decl-dtor.cpp
instantiate-decl-init.cpp
instantiate-declref-ice.cpp
instantiate-declref.cpp
instantiate-deeply.cpp
instantiate-default-assignment-operator.cpp
instantiate-dependent-nested-name.cpp
instantiate-elab-type-specifier.cpp
instantiate-enum-2.cpp
instantiate-enum.cpp
instantiate-exception-spec-cxx11.cpp
instantiate-exception-spec.cpp
instantiate-expanded-type-constraint.cpp [Concepts] Deprecate -fconcepts-ts, enable Concepts under -std=c++2a 2020-01-24 00:48:59 +02:00
instantiate-explicitly-after-fatal.cpp
instantiate-expr-1.cpp
instantiate-expr-2.cpp
instantiate-expr-3.cpp [AST][RecoveryExpr] Preserve the AST for invalid conditions. 2020-07-20 14:58:36 +02:00
instantiate-expr-4.cpp Check for qualified function types after substituting into the operand 2019-10-03 18:55:23 +00:00
instantiate-expr-5.cpp
instantiate-expr-6.cpp
instantiate-expr-basic.cpp
instantiate-field.cpp
instantiate-friend-class.cpp
instantiate-friend-function.cpp PR43400: Add test that we can instantiate a friend function that is 2019-10-27 12:41:53 -07:00
instantiate-function-1.cpp
instantiate-function-1.mm
instantiate-function-2.cpp Implement P1766R1: diagnose giving non-C-compatible classes a typedef name for linkage purposes. 2020-02-07 11:47:37 -08:00
instantiate-function-params.cpp [AST][RecoveryExpr] Build recovery expressions by default for C++. 2020-06-12 15:21:38 +02:00
instantiate-incomplete-typo-suggested-error-limit.cpp Fixes an assertion while instantiating a template with an incomplete typo-corrected type. 2019-09-07 20:14:09 +00:00
instantiate-init.cpp Revert "Rename llvm::array_lengthof into llvm::size to match std::size from C++17" 2022-01-26 16:55:53 +01:00
instantiate-invalid.cpp
instantiate-local-class.cpp Recommit: Compress formatting of array type names (int [4] -> int[4]) 2021-10-21 11:34:43 -07:00
instantiate-member-class.cpp [Sema][C++] Propagate conversion kind to specialize the diagnostics 2020-02-25 16:05:37 +00:00
instantiate-member-expr.cpp [AST] Print a<b<c>> without extra spaces in C++11 or later. 2020-03-26 09:53:54 +01:00
instantiate-member-initializers.cpp
instantiate-member-pointers.cpp
instantiate-member-specialization.cpp Properly collect template arguments from a class-scope function template 2020-11-10 15:55:19 -08:00
instantiate-member-template.cpp
instantiate-method.cpp
instantiate-non-dependent-types.cpp
instantiate-non-type-template-parameter.cpp
instantiate-objc-1.mm
instantiate-overload-candidates.cpp
instantiate-overloaded-arrow.cpp
instantiate-partial-spec.cpp
instantiate-requires-clause.cpp PR50402: Use proper constant evaluation rules for checking constraint 2021-05-19 16:02:53 -07:00
instantiate-requires-expr.cpp [Concepts] Fix incorrect DeclContext for transformed RequiresExprBodyDecl 2020-03-10 23:17:00 +02:00
instantiate-scope.cpp
instantiate-self.cpp Explain why the array bound is non-constant in VLA diagnostics. 2020-08-19 15:45:51 -07:00
instantiate-sizeof.cpp
instantiate-static-local.cpp Where possible, don't try to ask whether a template argument is 2020-12-17 23:23:05 -08:00
instantiate-static-var.cpp Recommit: Compress formatting of array type names (int [4] -> int[4]) 2021-10-21 11:34:43 -07:00
instantiate-subscript.cpp [C++2b] Implement multidimentional subscript operator 2022-02-08 12:10:47 -05:00
instantiate-template-argument.cpp [Concepts] Correctly form initial parameter mapping for parameter packs, support substitution into SubstNonTypeTemplateParmExpr 2020-01-31 15:59:42 +02:00
instantiate-template-template-parm.cpp Revert "[clang] deprecate frelaxed-template-template-args, make it on by default" 2021-11-02 17:02:19 -04:00
instantiate-try-catch.cpp
instantiate-type.cpp
instantiate-typedef.cpp
instantiate-typeof.cpp
instantiate-using-decl.cpp
instantiate-var-template.cpp [clang] NFC: include non friendly types and missing sugar in test expectations 2021-10-27 23:03:29 +02:00
instantiation-backtrace.cpp
instantiation-default-1.cpp Suppress printing template arguments that match default template 2020-11-11 15:05:51 -08:00
instantiation-default-2.cpp
instantiation-default-3.cpp
instantiation-dependence.cpp Fix miscomputation of dependence for elaborated types that are 2021-02-04 13:14:15 -08:00
instantiation-depth-defarg.cpp
instantiation-depth-default.cpp Update line number after previous patch added an additional unsupported 2019-12-12 14:45:05 -08:00
instantiation-depth-exception-spec.cpp
instantiation-depth-subst-2.cpp
instantiation-depth-subst.cpp
instantiation-depth.cpp
instantiation-order.cpp
issue150.cpp
lambda-capture-pack.cpp Diagnose -Wunused-value based on CFG reachability 2021-09-28 10:00:15 -07:00
late-parsing-eager-instantiation.cpp [Diagnostics] Try to improve warning message for -Wreturn-type 2019-11-09 17:54:58 +01:00
lookup-dependent-bases.cpp
matrix-type.cpp Add type information to integral template argument if required. 2021-05-12 19:00:08 +00:00
member-access-ambig.cpp
member-access-expr.cpp Don't form a 'context-independent expr' reference to a member during 2020-07-27 19:38:22 -07:00
member-function-template.cpp
member-inclass-init-value-dependent.cpp
member-initializers.cpp
member-specialization.cpp
member-template-access-expr.cpp
metafun-apply.cpp
missing-class-keyword-crash.cpp
missing-typename.cpp
ms-class-specialization-class-scope.cpp
ms-class-specialization-duplicate.cpp
ms-delayed-default-template-args.cpp Improve error recovery from missing '>' in template argument list. 2020-03-27 18:59:01 -07:00
ms-function-specialization-class-scope.cpp
ms-if-exists.cpp
ms-lookup-template-base-classes.cpp PR48339: Improve diagnostics for invalid dependent unqualified function calls. 2020-12-02 17:54:55 -08:00
ms-sizeof-missing-typename.cpp
nested-deduction-guides.cpp
nested-incomplete-class.cpp
nested-linkage.cpp
nested-name-spec-template.cpp PR45294: Fix handling of assumed template names looked up in the lexical 2020-03-27 21:07:06 -07:00
nested-template.cpp Revert "[clang] deprecate frelaxed-template-template-args, make it on by default" 2021-11-02 17:02:19 -04:00
non-integral-switch-cond.cpp Reapply "Fix crash on switch conditions of non-integer types in templates" 2019-12-03 15:27:19 -08:00
nss-recovery.cpp [AST][RecoveryExpr] Avoid spurious 'missing typename' diagnostic when the NNS contains errors. 2020-06-30 16:18:32 +02:00
operator-function-id-template.cpp
operator-template.cpp [clang] retain type sugar in auto / template argument deduction 2021-11-15 23:07:45 +01:00
overload-candidates.cpp
overload-uneval.cpp
overloaded-functions.cpp
pack-deduction.cpp Recommit: Compress formatting of array type names (int [4] -> int[4]) 2021-10-21 11:34:43 -07:00
partial-order.cpp
partial-spec-instantiate.cpp When performing template argument deduction to select a partial 2021-05-05 14:47:18 -07:00
pr47676.cpp [clang][Sema] Fix PR47676: Handle dependent AltiVec C-style cast 2020-10-01 15:57:01 -04:00
pr52909.cpp [clang] Correctly(?) handle placeholder types in ExprRequirements. 2022-02-01 15:16:17 -05:00
pr52970.cpp [clang] Don't typo-fix an expression in a SFINAE context. 2022-02-01 15:17:28 -05:00
pragma-ms_struct.cpp
qualified-id.cpp
qualified-names-diag.cpp
rdar9173693.cpp Remove redundant CXXScopeSpec from TemplateIdAnnotation. 2020-01-17 15:47:21 -08:00
recovery-crash.cpp PR48339: Improve diagnostics for invalid dependent unqualified function calls. 2020-12-02 17:54:55 -08:00
recovery-tree-transform-crash.cpp [AST][RecoveryExpr] Fix the missing type when rebuilding RecoveryExpr in TreeTransform. 2020-08-07 11:15:19 +02:00
recovery-tree-transform.cpp [AST] Add RecoveryExpr to retain expressions on semantic errors 2020-03-24 09:20:37 +01:00
recursive-template-instantiation.cpp
resolve-single-template-id.cpp [clang] Stop providing builtin overload candidate for relational function pointer comparisons 2021-06-26 00:08:02 +02:00
self-comparison.cpp
sizeof-pack.cpp
stack-exhaustion.cpp Fix check-all with -DLLVM_USE_SANITIZER=Address 2020-07-10 01:47:51 -07:00
stmt-expr.cpp
subst-into-subst.cpp Teach TreeTransform to substitute into resolved TemplateArguments. 2020-03-19 12:43:11 -07:00
temp-param-subst-linear.cpp
temp.cpp Part of C++ DR 39: a class member lookup is not ambiguous if it finds the 2020-11-25 17:03:11 -08:00
temp_arg.cpp Improve recovery from invalid template-ids. 2020-03-27 17:11:04 -07:00
temp_arg_enum_printing.cpp Add type information to integral template argument if required. 2021-05-12 19:00:08 +00:00
temp_arg_enum_printing_more.cpp
temp_arg_nontype.cpp [clang] NFC: include non friendly types and missing sugar in test expectations 2021-10-27 23:03:29 +02:00
temp_arg_nontype_cxx1z.cpp [clang] NFC: include non friendly types and missing sugar in test expectations 2021-10-27 23:03:29 +02:00
temp_arg_nontype_cxx11.cpp Fix type printing of array template args 2021-05-01 18:50:09 +00:00
temp_arg_nontype_cxx20.cpp Add test for PR50039. 2021-05-11 17:35:34 -07:00
temp_arg_pack.cpp
temp_arg_string_printing.cpp [AST] Print NTTP args as string-literals when possible 2022-03-01 19:34:27 -06:00
temp_arg_template.cpp Revert "[clang] deprecate frelaxed-template-template-args, make it on by default" 2021-11-02 17:02:19 -04:00
temp_arg_template_cxx1z.cpp Revert "[clang] deprecate frelaxed-template-template-args, make it on by default" 2021-11-02 17:02:19 -04:00
temp_arg_type.cpp
temp_class_order.cpp
temp_class_spec.cpp [clang] Invalidate a non-dependent-type RecordDecl when it has any dependent-type base class specifier. 2021-05-20 15:33:05 +02:00
temp_class_spec_blocks.cpp
temp_class_spec_neg.cpp
temp_explicit.cpp
temp_explicit_cxx0x.cpp
temp_func_order.cpp
template-class-traits.cpp
template-decl-fail.cpp PR46231: Promote diagnostic for 'template<...>;' from ExtWarn to Error. 2020-07-29 12:35:18 -07:00
template-id-expr.cpp
template-id-printing.cpp
typename-specifier-2.cpp
typename-specifier-3.cpp
typename-specifier-4.cpp Part of C++ DR 39: a class member lookup is not ambiguous if it finds the 2020-11-25 17:03:11 -08:00
typename-specifier.cpp
typo-dependent-name.cpp Revert "PR47805: Use a single object for a function parameter in the caller and" 2020-10-13 19:32:03 -07:00
typo-template-name.cpp
typo-variadic.cpp [SemaTemplate] Fix uncorrected typos after pack expansion 2019-07-16 10:30:21 +00:00
undeclared-template.cpp PR45207: Fix crash if constrained-type-specifier annotation forms a 2020-03-17 13:18:23 -07:00
undefined-template.cpp
unresolved-construct.cpp
unused-variables.cpp
using-decl.cpp Always rebuild a DeclRefExpr if its FoundDecl would change. 2019-09-26 22:28:32 +00:00
value-dependent-bitfield-cond.cpp Fix type-dependency of bitfields in templates 2020-02-12 13:31:41 -08:00
value-dependent-null-pointer-constant.cpp
virtual-member-functions.cpp
warn-thread-safety-analysis.cpp