| 1 |
// RUN: %clang_cc1 -fallow-pch-with-compiler-errors -std=c++20 -x c++-header -emit-pch %s -o %t -verify |
| 2 |
// RUN: %clang_cc1 -fallow-pch-with-compiler-errors -std=c++20 -include-pch %t %s -verify |
| 3 |
#ifndef HEADER_H |
| 4 |
#define HEADER_H |
| 5 |
|
| 6 |
#include "bad_include.h" |
| 7 |
// expected-error@6{{'bad_include.h' file not found}} |
| 8 |
|
| 9 |
template <bool, class = void> struct enable_if {}; |
| 10 |
template <class T> struct enable_if<true, T> { typedef T type; }; |
| 11 |
template <bool B, class T = void> using enable_if_t = typename enable_if<B, T>::type; |
| 12 |
|
| 13 |
template <typename> struct meta { static constexpr int value = 0; }; |
| 14 |
template <> struct meta<int> { static constexpr int value = 1; }; |
| 15 |
template <> struct meta<float> { static constexpr int value = 2; }; |
| 16 |
|
| 17 |
namespace N { |
| 18 |
inline namespace inner { |
| 19 |
|
| 20 |
template <class T> |
| 21 |
constexpr enable_if_t<meta<T>::value == 0, void> midpoint(T) {} |
| 22 |
|
| 23 |
template <class U> |
| 24 |
constexpr enable_if_t<meta<U>::value == 1, void> midpoint(U) {} |
| 25 |
|
| 26 |
template <class F> |
| 27 |
constexpr enable_if_t<meta<F>::value == 2, void> midpoint(F) {} |
| 28 |
|
| 29 |
} // namespace inner |
| 30 |
} // namespace N |
| 31 |
|
| 32 |
#else |
| 33 |
|
| 34 |
// expected-error@27{{'N::midpoint' has different definitions in different modules; defined here first difference is 1st parameter with type 'F'}} |
| 35 |
// expected-error@24{{'N::midpoint' has different definitions in different modules; defined here first difference is 1st parameter with type 'U'}} |
| 36 |
// expected-note@21{{but in '' found 1st parameter with type 'T'}} |
| 37 |
int x = N::something; |
| 38 |
// expected-error@37{{no member named 'something' in namespace 'N'}} |
| 39 |
// expected-note@21{{but in '' found 1st parameter with type 'T'}} |
| 40 |
|
| 41 |
#endif |