[PATCH] D119609: [Clang][Sema] Prohibit expr statement in the default argument

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 4 07:24:45 PDT 2022

erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

I think LGTM on technical perspective, Please don't commit until @aaron.ballman confirms he is OK with the direction, or would like to wait longer for GCC.

Comment at: clang/test/Sema/err-expr-stmt-in-default-arg.cpp:3
+void foo() {
+  void fn(int i, int = ({ 1; })); // expected-error {{expression statement not permitted in default argument}}
erichkeane wrote:
> Do we also prohibit in a template argument?
Template args were already disallowed, right?  Presumably there is a test for that?

Comment at: clang/test/Sema/err-expr-stmt-in-default-arg.cpp:10
+  void fn(int i, int j = ({{}, {}, {,}}), int k = ""); // expected-error {{expression statement not permitted in default argument}} expected-error {{cannot initialize a parameter of type 'int' with an lvalue of type 'const char[1]'}} expected-note {{passing argument to parameter 'k' here}}
junaire wrote:
> @erichkeane Do you mean this one? Or I get you wrong?
Ah, missed that, thank you!  This is sufficient for my concerns.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list