brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 752b0cc Raw
42 lines · cpp
1// RUN: %clang_cc1 -fallow-pch-with-compiler-errors -std=c++20 -x c++-header -emit-pch %s -o %t -verify2// RUN: %clang_cc1 -fallow-pch-with-compiler-errors -std=c++20 -include-pch %t %s -verify3#ifndef HEADER_H4#define HEADER_H5 6#include "bad_include.h"7// expected-error@6{{'bad_include.h' file not found}}8 9template <bool, class = void> struct enable_if {};10template <class T> struct enable_if<true, T> { typedef T type; };11template <bool B, class T = void> using enable_if_t = typename enable_if<B, T>::type;12 13template <typename> struct meta { static constexpr int value = 0; };14template <> struct meta<int> { static constexpr int value = 1; };15template <> struct meta<float> { static constexpr int value = 2; };16 17namespace N {18inline namespace inner {19 20template <class T>21constexpr enable_if_t<meta<T>::value == 0, void> midpoint(T) {}22 23template <class U>24constexpr enable_if_t<meta<U>::value == 1, void> midpoint(U) {}25 26template <class F>27constexpr enable_if_t<meta<F>::value == 2, void> midpoint(F) {}28 29} // namespace inner30} // namespace N31 32#else33 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'}}37int 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#endif42