From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/SemaCXX/cxx0x-compat.cpp | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 clang/test/SemaCXX/cxx0x-compat.cpp (limited to 'clang/test/SemaCXX/cxx0x-compat.cpp') diff --git a/clang/test/SemaCXX/cxx0x-compat.cpp b/clang/test/SemaCXX/cxx0x-compat.cpp new file mode 100644 index 0000000..123008a --- /dev/null +++ b/clang/test/SemaCXX/cxx0x-compat.cpp @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -verify %s + +namespace N { + template void f(T) {} // expected-note 2{{here}} + namespace M { + template void ::N::f(int); // expected-warning {{explicit instantiation of 'f' not in a namespace enclosing 'N'}} + } +} +using namespace N; +template void f(char); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}} + +template void g(T) {} // expected-note 2{{here}} +namespace M { + template void g(int); // expected-warning {{explicit instantiation of 'g' must occur at global scope}} + template void ::g(char); // expected-warning {{explicit instantiation of 'g' must occur at global scope}} +} + +template inline void g(double); // expected-warning {{explicit instantiation cannot be 'inline'}} + +void g() { + auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}} +} + +int n; +struct S { + char c; +} +s = { n }, // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++11}} expected-note {{explicit cast}} +t = { 1234 }; // expected-warning {{constant expression evaluates to 1234 which cannot be narrowed to type 'char' in C++11}} expected-warning {{changes value}} expected-note {{explicit cast}} + +#define PRIuS "uS" +int printf(const char *, ...); +typedef __typeof(sizeof(int)) size_t; +void h(size_t foo, size_t bar) { + printf("foo is %"PRIuS", bar is %"PRIuS, foo, bar); // expected-warning 2{{identifier after literal will be treated as a reserved user-defined literal suffix in C++11}} +} + +#define _x + 1 +char c = 'x'_x; // expected-warning {{will be treated as a user-defined literal suffix}} -- cgit v1.2.3