llvm-project/llvm/test/TableGen/cond-subclass.td
Cullen Rhodes d968b173d3 [TableGen] Emit a warning for unused template args
Add a warning to TableGen for unused template arguments in classes and
multiclasses, for example:

  multiclass Foo<int x> {
    def bar;
  }

  $ llvm-tblgen foo.td

  foo.td:1:20: warning: unused template argument: Foo::x
  multiclass Foo<int x> {
                     ^
A flag '--no-warn-on-unused-template-args' is added to disable the
warning. The warning is disabled for LLVM and sub-projects if
'LLVM_ENABLE_WARNINGS=OFF'.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D109359
2021-11-03 11:55:07 +00:00

28 lines
549 B
TableGen

// Check that !cond with operands of different subtypes can
// initialize a supertype variable.
// RUN: llvm-tblgen --no-warn-on-unused-template-args %s | FileCheck %s
// XFAIL: vg_leak
class E<int dummy> {}
class E1<int dummy> : E<dummy> {}
class E2<int dummy> : E<dummy> {}
class EX<int cc, E1 b, E2 c> {
E x = !cond(cc: b, 1 : c);
}
def E1d : E1<0>;
def E2d : E2<0>;
def EXd1 : EX<1, E1d, E2d>;
def EXd2 : EX<0, E1d, E2d>;
// CHECK: def EXd1 {
// CHECK: E x = E1d;
// CHECK: }
//
// CHECK: def EXd2 {
// CHECK: E x = E2d;
// CHECK: }