<div dir="ltr"><div dir="ltr">On Fri, 6 Mar 2020 at 02:11, Stephan Herhut via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Author: Stephan Herhut<br>
Date: 2020-03-06T11:09:45+01:00<br>
New Revision: 8e4a8677be3061317056335d298d85ce60c23dff<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/8e4a8677be3061317056335d298d85ce60c23dff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/8e4a8677be3061317056335d298d85ce60c23dff</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/8e4a8677be3061317056335d298d85ce60c23dff.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/8e4a8677be3061317056335d298d85ce60c23dff.diff</a><br>
<br>
LOG: Revert "PR45083: Mark statement expressions as being dependent if they contain"<br>
<br>
This reverts commit a95cc77be154433c37a3110ac9af394b7447fcba.<br>
<br>
Causes an internal build failure. I followed up with the author by mail.<br></blockquote><div><br></div><div>The internal build failure is on invalid code that Clang incorrectly accepted previously. Unreverting...</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Added: <br>
<br>
<br>
Modified: <br>
clang/include/clang/AST/Expr.h<br>
clang/lib/AST/Expr.cpp<br>
clang/test/SemaTemplate/dependent-expr.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h<br>
index 75b7a5f6ecd3..7271dbb830a2 100644<br>
--- a/clang/include/clang/AST/Expr.h<br>
+++ b/clang/include/clang/AST/Expr.h<br>
@@ -3959,8 +3959,14 @@ class StmtExpr : public Expr {<br>
Stmt *SubStmt;<br>
SourceLocation LParenLoc, RParenLoc;<br>
public:<br>
- StmtExpr(CompoundStmt *SubStmt, QualType T,<br>
- SourceLocation LParen, SourceLocation RParen);<br>
+ // FIXME: Does type-dependence need to be computed <br>
diff erently?<br>
+ // FIXME: Do we need to compute instantiation instantiation-dependence for<br>
+ // statements? (ugh!)<br>
+ StmtExpr(CompoundStmt *substmt, QualType T,<br>
+ SourceLocation lp, SourceLocation rp) :<br>
+ Expr(StmtExprClass, T, VK_RValue, OK_Ordinary,<br>
+ T->isDependentType(), false, false, false),<br>
+ SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }<br>
<br>
/// Build an empty statement expression.<br>
explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }<br>
<br>
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp<br>
index 78fd96fd76e6..79f9f42224d0 100644<br>
--- a/clang/lib/AST/Expr.cpp<br>
+++ b/clang/lib/AST/Expr.cpp<br>
@@ -4097,53 +4097,6 @@ void ExtVectorElementExpr::getEncodedElementAccess(<br>
}<br>
}<br>
<br>
-StmtExpr::StmtExpr(CompoundStmt *SubStmt, QualType T, SourceLocation LParen,<br>
- SourceLocation RParen)<br>
- : Expr(StmtExprClass, T, VK_RValue, OK_Ordinary, T->isDependentType(),<br>
- false, false, false),<br>
- SubStmt(SubStmt), LParenLoc(LParen), RParenLoc(RParen) {<br>
- llvm::SmallVector<Stmt*, 16> Queue(1, SubStmt);<br>
- while (!Queue.empty()) {<br>
- Stmt *S = Queue.pop_back_val();<br>
- if (!S)<br>
- continue;<br>
-<br>
- // If any subexpression is dependent, the statement expression is dependent<br>
- // in the same way.<br>
- if (Expr *E = dyn_cast<Expr>(S)) {<br>
- addDependence(E->getDependence());<br>
- continue;<br>
- }<br>
-<br>
- // FIXME: Need to properly compute whether DeclStmts contain unexpanded<br>
- // parameter packs.<br>
- if (DeclStmt *DS = dyn_cast<DeclStmt>(S)) {<br>
- for (Decl *D : DS->decls()) {<br>
- // If any contained declaration is in a dependent context, then it<br>
- // needs to be instantiated, so the statement expression itself is<br>
- // instantiation-dependent.<br>
- //<br>
- // Note that we don't need to worry about the case where the context is<br>
- // non-dependent but contains dependent entities here (eg, inside a<br>
- // variable template or alias template): that can only happen at file<br>
- // scope, where statement expressions are prohibited.<br>
- if (D->getLexicalDeclContext()->isDependentContext())<br>
- addDependence(ExprDependence::Instantiation);<br>
-<br>
- // If any contained variable declaration has a dependent type, we can't<br>
- // evaluate that declaration.<br>
- if (auto *VD = dyn_cast<VarDecl>(D))<br>
- if (VD->getType()->isDependentType())<br>
- addDependence(ExprDependence::Value);<br>
- }<br>
- }<br>
-<br>
- // Recurse to substatements.<br>
- // FIXME: Should we skip the unchosen side of 'if constexpr' if known?<br>
- Queue.insert(Queue.end(), S->child_begin(), S->child_end());<br>
- }<br>
-}<br>
-<br>
ShuffleVectorExpr::ShuffleVectorExpr(const ASTContext &C, ArrayRef<Expr*> args,<br>
QualType Type, SourceLocation BLoc,<br>
SourceLocation RP)<br>
<br>
diff --git a/clang/test/SemaTemplate/dependent-expr.cpp b/clang/test/SemaTemplate/dependent-expr.cpp<br>
index 12a99acc21cd..bb1e239c3490 100644<br>
--- a/clang/test/SemaTemplate/dependent-expr.cpp<br>
+++ b/clang/test/SemaTemplate/dependent-expr.cpp<br>
@@ -1,4 +1,5 @@<br>
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s<br>
+// RUN: %clang_cc1 -fsyntax-only -verify %s<br>
+// expected-no-diagnostics<br>
<br>
// PR5908<br>
template <typename Iterator><br>
@@ -107,42 +108,3 @@ namespace PR18152 {<br>
};<br>
template struct A<0>;<br>
}<br>
-<br>
-template<typename T> void stmt_expr_1() {<br>
- // GCC doesn't check this: it appears to treat statement-expressions as being<br>
- // value-dependent if they appear in a dependent context, regardless of their<br>
- // contents.<br>
- static_assert( ({ false; }), "" ); // expected-error {{failed}}<br>
-}<br>
-void stmt_expr_2() {<br>
- static_assert( ({ false; }), "" ); // expected-error {{failed}}<br>
-}<br>
-<br>
-namespace PR45083 {<br>
- struct A { bool x; };<br>
-<br>
- template<typename> struct B : A {<br>
- void f() {<br>
- const int n = ({ if (x) {} 0; });<br>
- }<br>
- };<br>
-<br>
- template void B<int>::f();<br>
-<br>
- template<typename> void f() {<br>
- decltype(({})) x; // expected-error {{incomplete type}}<br>
- }<br>
- template void f<int>();<br>
-<br>
- template<typename> auto g() {<br>
- auto c = [](auto, int) -> decltype(({})) {};<br>
- using T = decltype(c(0.0, 0));<br>
- using T = void;<br>
- return c(0, 0);<br>
- }<br>
- using U = decltype(g<int>()); // expected-note {{previous}}<br>
- using U = float; // expected-error {{<br>
diff erent types ('float' vs 'decltype(g<int>())' (aka 'void'))}}<br>
-<br>
- void h(auto a, decltype(g<char>())*) {} // expected-note {{previous}}<br>
- void h(auto a, void*) {} // expected-error {{redefinition}}<br>
-}<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>