brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 998f2cc Raw
45 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only %s -std=c++142 3// Checks that Clang doesn't crash/assert on the nested call to "kaboom"4// in "bar()".5//6// This is an interesting test case for `ExprConstant.cpp`'s `CallStackFrame`7// because it triggers the following chain of events:8// 0. `CheckEnableIf` calls `EvaluateWithSubstitution`.9//  1. The outer call to "kaboom" gets evaluated.10//   2. The expr for "a" gets evaluated, it has a version X;11//      a temporary with the key (a, X) is created.12//     3. The inner call to "kaboom" gets evaluated.13//       4. The expr for "a" gets evaluated, it has a version Y;14//          a temporary with the key (a, Y) is created.15//       5. The expr for "b" gets evaluated, it has a version Y;16//          a temporary with the key (b, Y) is created.17//   6. `EvaluateWithSubstitution` looks at "b" but cannot evaluate it18//      because it's value-dependent (due to the call to "f.foo()").19//20// When `EvaluateWithSubstitution` bails out while evaluating the outer21// call, it attempts to fetch "b"'s param slot to clean it up.22//23// This used to cause an assertion failure in `getTemporary` because24// a temporary with the key "(b, Y)" (created at step 4) existed but25// not one for "(b, X)", which is what it was trying to fetch.26 27template<typename T>28__attribute__((enable_if(true, "")))29T kaboom(T a, T b) {30  return b;31}32 33struct A {34  double foo();35};36 37template <int>38struct B {39  A &f;40 41  void bar() {42    kaboom(kaboom(0.0, 1.0), f.foo());43  }44};45