The assertion doesn't seem to hold due to ASTMatchers traversing code
inside GNU StmtExpr twice. This can screw up our algorithm's invariants.
We need a further investigation to properly fix this issue, but for now
let's avoid the crash.
void discoverDecl(const DeclStmt *DS) {
for (const Decl *D : DS->decls()) {
if (const auto *VD = dyn_cast<VarDecl>(D)) {
- assert(Defs.count(VD) == 0 && "Definition already discovered!");
+ // FIXME: Assertion temporarily disabled due to a bug in
+ // ASTMatcher internal behavior in presence of GNU
+ // statement-expressions. We need to properly investigate this
+ // because it can screw up our algorithm in other ways.
+ // assert(Defs.count(VD) == 0 && "Definition already discovered!");
Defs[VD] = DS;
}
}
--- /dev/null
+// RUN: %clang_cc1 -Wunsafe-buffer-usage %s -verify %s
+
+void gnu_stmtexpr_crash(void) {
+ struct A {};
+ struct B {
+ struct A a;
+ };
+
+ struct B b = {{
+ // This is a statement-expression (GNU extension).
+ ({ int x; }) // no-crash // expected-warning{{excess elements in struct initializer}}
+ }};
+}