summaryrefslogtreecommitdiffstats
path: root/tests/cxx/consteval.cc
blob: 3d4652b77e3350a76d9fc6f99e1be88fa2415cff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//===--- consteval.cc - test input file for iwyu --------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// IWYU_ARGS: -I . -std=c++20

// These tests are not particularly interesting in themselves, but they cover an
// upstream bug in Clang (https://github.com/llvm/llvm-project/issues/53044) for
// which we have a workaround.

#include "tests/cxx/direct.h"

struct X {
  // IWYU: IndirectClass needs a declaration
  consteval X(const IndirectClass& v) {
  }

  // IWYU: IndirectClass needs a declaration
  consteval operator IndirectClass*() const {
    return nullptr;
  }
};

void t() {
  // Pass value through Consteval conversion constructor.
  // IWYU: IndirectClass is...*indirect.h
  IndirectClass a;
  X x = a;

  // Try an implicit consteval user-defined conversion too.
  // IWYU: IndirectClass needs a declaration
  IndirectClass* b = x;
}

/**** IWYU_SUMMARY

tests/cxx/consteval.cc should add these lines:
#include "tests/cxx/indirect.h"

tests/cxx/consteval.cc should remove these lines:
- #include "tests/cxx/direct.h"  // lines XX-XX

The full include-list for tests/cxx/consteval.cc:
#include "tests/cxx/indirect.h"  // for IndirectClass

***** IWYU_SUMMARY */