[PATCH] D82284: [AST][RecoveryAST] Preseve invalid return stmt, and suppress the diagnostics for missing return stmt in constexpr func.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 22 02:06:31 PDT 2020


sammccall added a comment.

This is a nice coverage improvement but diagnostic changes don't seem to particularly be improvements...  not opposed to landing as-is but want to consider if we can mitigate these...



================
Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:1798
+  constexpr int error() { // expected-error {{constexpr function never produces a constant expression}}
+    return foobar; // expected-error {{undeclared identifier}} expected-note 2{{subexpression not valid in a constant expression}}
   }
----------------
an idea (not sure if feasible) - do we want to suppress "not valid in constant expression" errors when the expressions contains errors?
If so, may want a (different) FIXME here


================
Comment at: clang/test/SemaCXX/lambda-expressions.cpp:522
       return undeclared_error; // expected-error {{use of undeclared identifier}}
-    return 0;
+    return 0; // expected-error {{cannot initialize return object of type 'auto' with an rvalue of type 'int'}}
   };
----------------
this seems like a regression - what exactly is going on here?

in a perfect world I guess we'd e.g. leave the type undeduced from the first return, rather than deduce it as undeduced-auto (at least for the purposes of diagnostics).


================
Comment at: clang/test/SemaCXX/typo-correction-crash.cpp:19
 using T1 = decltype(L1());
-static_assert(is_same<T1, void>::value, "Return statement should be discarded");
+// FIXME: Suppress the 'undeclared identifier T1' diagnostic, the UsingDecl T1 is discarded because of an invalid L1().
+static_assert(is_same<T1, void>::value, "Return statement should be discarded"); // expected-error {{use of undeclared identifier 'T1'}}
----------------
this is also a regression, though this code is pretty broken and is really just asserting no crash.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82284/new/

https://reviews.llvm.org/D82284





More information about the cfe-commits mailing list