blob: 927df1f971e991a9bc882de88fd7af686e75bf93 [file] [log] [blame]
Richard Smith41be6732011-10-14 20:48:27 +00001// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
Richard Smith84ef8992011-10-14 20:41:13 +00002
3template<typename ...T> // expected-warning {{variadic templates are incompatible with C++98}}
4class Variadic1 {};
5
6template<template<typename> class ...T> // expected-warning {{variadic templates are incompatible with C++98}}
7class Variadic2 {};
8
9template<int ...I> // expected-warning {{variadic templates are incompatible with C++98}}
10class Variadic3 {};
Richard Smith41be6732011-10-14 20:48:27 +000011
12int alignas(8) with_alignas; // expected-warning {{'alignas' is incompatible with C++98}}
13int with_attribute [[ ]]; // expected-warning {{attributes are incompatible with C++98}}
Richard Smith661a9962011-10-15 01:18:56 +000014
15void Literals() {
16 (void)u8"str"; // expected-warning {{unicode literals are incompatible with C++98}}
17 (void)u"str"; // expected-warning {{unicode literals are incompatible with C++98}}
18 (void)U"str"; // expected-warning {{unicode literals are incompatible with C++98}}
19 (void)u'x'; // expected-warning {{unicode literals are incompatible with C++98}}
20 (void)U'x'; // expected-warning {{unicode literals are incompatible with C++98}}
21
22 (void)u8R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
23 (void)uR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
24 (void)UR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
25 (void)R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
26 (void)LR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
27}
28
29template<typename T> struct S {};
Richard Smith7fe62082011-10-15 05:09:34 +000030namespace TemplateParsing {
31 S<::S<void> > s; // expected-warning {{'<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98}}
32 S< ::S<void>> t; // expected-warning {{consecutive right angle brackets are incompatible with C++98 (use '> >')}}
33}
34
35void Lambda() {
36 []{}; // expected-warning {{lambda expressions are incompatible with C++98}}
37}
38
39int InitList() {
40 (void)new int {}; // expected-warning {{generalized initializer lists are incompatible with C++98}}
41 (void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}}
42 int x {}; // expected-warning {{generalized initializer lists are incompatible with C++98}}
43 return {}; // expected-warning {{generalized initializer lists are incompatible with C++98}}
44}
45
46int operator""_hello(const char *); // expected-warning {{literal operators are incompatible with C++98}}
47
48enum EnumFixed : int { // expected-warning {{enumeration types with a fixed underlying type are incompatible with C++98}}
49};
50
51enum class EnumScoped { // expected-warning {{scoped enumerations are incompatible with C++98}}
52};
53
54void Deleted() = delete; // expected-warning {{deleted function definitions are incompatible with C++98}}
55struct Defaulted {
56 Defaulted() = default; // expected-warning {{defaulted function definitions are incompatible with C++98}}
57};
58
59int &&RvalueReference = 0; // expected-warning {{rvalue references are incompatible with C++98}}
60struct RefQualifier {
61 void f() &; // expected-warning {{reference qualifiers on functions are incompatible with C++98}}
62};
63
64auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}}
65
66void RangeFor() {
67 int xs[] = {1, 2, 3};
68 for (int &a : xs) { // expected-warning {{range-based for loop is incompatible with C++98}}
69 }
70}
71
72struct InClassInit {
73 int n = 0; // expected-warning {{in-class initialization of non-static data members is incompatible with C++98}}
74};
75
76struct OverrideControlBase {
77 virtual void f();
78 virtual void g();
79};
80struct OverrideControl final : OverrideControlBase { // expected-warning {{'final' keyword is incompatible with C++98}}
81 virtual void f() override; // expected-warning {{'override' keyword is incompatible with C++98}}
82 virtual void g() final; // expected-warning {{'final' keyword is incompatible with C++98}}
83};
84
85using AliasDecl = int; // expected-warning {{alias declarations are incompatible with C++98}}
86template<typename T> using AliasTemplate = T; // expected-warning {{alias declarations are incompatible with C++98}}
87
88inline namespace N { // expected-warning {{inline namespaces are incompatible with C++98}}
89}
Richard Smith0aa86c02011-10-15 05:42:01 +000090
91auto auto_deduction = 0; // expected-warning {{'auto' type specifier is incompatible with C++98}}
92int *p = new auto(0); // expected-warning {{'auto' type specifier is incompatible with C++98}}