Clang Project

clang_source_code/test/SemaCXX/cxx14-compat.cpp
1// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++14-compat-pedantic -verify %s
2// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++14-compat-pedantic -verify %s
3
4#if __cplusplus < 201402L
5
6// expected-no-diagnostics
7// FIXME: C++11 features removed or changed in C++14?
8
9#else
10
11static_assert(true); // expected-warning {{incompatible with C++ standards before C++17}}
12
13template<int ...N> int f() { return (N + ...); } // expected-warning {{incompatible with C++ standards before C++17}}
14
15namespace [[]] NS_with_attr {} // expected-warning {{incompatible with C++ standards before C++17}}
16enum { e [[]] }; // expected-warning {{incompatible with C++ standards before C++17}}
17
18template<typename T = int> struct X {};
19X x; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17; for compatibility, use explicit type name 'X<int>'}}
20
21template<template<typename> class> struct Y {};
22Y<X> yx; // ok, not class template argument deduction
23
24template<typename T> void f(T t) {
25  X x = t; // expected-warning {{incompatible}}
26}
27
28template<typename T> void g(T t) {
29  typename T::X x = t; // expected-warning {{incompatible}}
30}
31struct A { template<typename T> struct X { X(T); }; };
32void h(A a) { g(a); } // expected-note {{in instantiation of}}
33
34#endif
35