+37
-17
lines changedFilter options
+37
-17
lines changed Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@
82
82
LANGOPT(C99 , 1, 0, "C99")
83
83
LANGOPT(C11 , 1, 0, "C11")
84
84
LANGOPT(C17 , 1, 0, "C17")
85
+
LANGOPT(C2x , 1, 0, "C2x")
85
86
LANGOPT(MSVCCompat , 1, 0, "Microsoft Visual C++ full compatibility mode")
86
87
LANGOPT(MicrosoftExt , 1, 0, "Microsoft C++ extensions")
87
88
LANGOPT(AsmBlocks , 1, 0, "Microsoft inline asm blocks")
Original file line number Diff line number Diff line change
@@ -22,16 +22,17 @@ enum LangFeatures {
22
22
C99 = (1 << 1),
23
23
C11 = (1 << 2),
24
24
C17 = (1 << 3),
25
-
CPlusPlus = (1 << 4),
26
-
CPlusPlus11 = (1 << 5),
27
-
CPlusPlus14 = (1 << 6),
28
-
CPlusPlus17 = (1 << 7),
29
-
CPlusPlus2a = (1 << 8),
30
-
Digraphs = (1 << 9),
31
-
GNUMode = (1 << 10),
32
-
HexFloat = (1 << 11),
33
-
ImplicitInt = (1 << 12),
34
-
OpenCL = (1 << 13)
25
+
C2x = (1 << 4),
26
+
CPlusPlus = (1 << 5),
27
+
CPlusPlus11 = (1 << 6),
28
+
CPlusPlus14 = (1 << 7),
29
+
CPlusPlus17 = (1 << 8),
30
+
CPlusPlus2a = (1 << 9),
31
+
Digraphs = (1 << 10),
32
+
GNUMode = (1 << 11),
33
+
HexFloat = (1 << 12),
34
+
ImplicitInt = (1 << 13),
35
+
OpenCL = (1 << 14)
35
36
};
36
37
37
38
}
@@ -73,6 +74,9 @@ struct LangStandard {
73
74
/// isC17 - Language is a superset of C17.
74
75
bool isC17() const { return Flags & frontend::C17; }
75
76
77
+
/// isC2x - Language is a superset of C2x.
78
+
bool isC2x() const { return Flags & frontend::C2x; }
79
+
76
80
/// isCPlusPlus - Language is a C++ variant.
77
81
bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
78
82
Original file line number Diff line number Diff line change
@@ -88,6 +88,14 @@ LANGSTANDARD(gnu17, "gnu17",
88
88
LineComment | C99 | C11 | C17 | Digraphs | GNUMode | HexFloat)
89
89
LANGSTANDARD_ALIAS(gnu17, "gnu18")
90
90
91
+
// C2x modes
92
+
LANGSTANDARD(c2x, "c2x",
93
+
C, "Working Draft for ISO C2x",
94
+
LineComment | C99 | C11 | C17 | C2x | Digraphs | HexFloat)
95
+
LANGSTANDARD(gnu2x, "gnu2x",
96
+
C, "Working Draft for ISO C2x with GNU extensions",
97
+
LineComment | C99 | C11 | C17 | C2x | Digraphs | GNUMode | HexFloat)
98
+
91
99
// C++ modes
92
100
LANGSTANDARD(cxx98, "c++98",
93
101
CXX, "ISO C++ 1998 with amendments",
Original file line number Diff line number Diff line change
@@ -2134,6 +2134,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
2134
2134
Opts.C99 = Std.isC99();
2135
2135
Opts.C11 = Std.isC11();
2136
2136
Opts.C17 = Std.isC17();
2137
+
Opts.C2x = Std.isC2x();
2137
2138
Opts.CPlusPlus = Std.isCPlusPlus();
2138
2139
Opts.CPlusPlus11 = Std.isCPlusPlus11();
2139
2140
Opts.CPlusPlus14 = Std.isCPlusPlus14();
@@ -2200,6 +2201,9 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
2200
2201
Opts.AlignedAllocation = Opts.CPlusPlus17;
2201
2202
2202
2203
Opts.DollarIdents = !Opts.AsmPreprocessor;
2204
+
2205
+
// Enable [[]] attributes in C++11 and C2x by default.
2206
+
Opts.DoubleSquareBracketAttributes = Opts.CPlusPlus11 || Opts.C2x;
2203
2207
}
2204
2208
2205
2209
/// Attempt to parse a visibility value out of the given argument.
@@ -2605,10 +2609,10 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
2605
2609
Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
2606
2610
Opts.Coroutines = Opts.CPlusPlus2a || Args.hasArg(OPT_fcoroutines_ts);
2607
2611
2608
-
// Enable [[]] attributes in C++11 by default.
2609
2612
Opts.DoubleSquareBracketAttributes =
2610
2613
Args.hasFlag(OPT_fdouble_square_bracket_attributes,
2611
-
OPT_fno_double_square_bracket_attributes, Opts.CPlusPlus11);
2614
+
OPT_fno_double_square_bracket_attributes,
2615
+
Opts.DoubleSquareBracketAttributes);
2612
2616
2613
2617
Opts.CPlusPlusModules = Opts.CPlusPlus2a;
2614
2618
Opts.ModulesTS = Args.hasArg(OPT_fmodules_ts);
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@
16
16
// CHECK-NEXT: note: use 'gnu11' for 'ISO C 2011 with GNU extensions' standard
17
17
// CHECK-NEXT: note: use 'c17', 'iso9899:2017', 'c18', or 'iso9899:2018' for 'ISO C 2017' standard
18
18
// CHECK-NEXT: note: use 'gnu17' or 'gnu18' for 'ISO C 2017 with GNU extensions' standard
19
+
// CHECK-NEXT: note: use 'c2x' for 'Working Draft for ISO C2x' standard
20
+
// CHECK-NEXT: note: use 'gnu2x' for 'Working Draft for ISO C2x with GNU extensions' standard
19
21
20
22
// Make sure that no other output is present.
21
23
// CHECK-NOT: {{^.+$}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
1
1
// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
2
+
// RUN: %clang_cc1 -fsyntax-only -std=gnu2x -verify %s
2
3
3
4
enum [[]] E {
4
5
One [[]],
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1
-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fdouble-square-bracket-attributes %s
1
+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c2x %s
2
2
3
3
struct S {};
4
4
struct S * [[clang::address_space(1)]] Foo;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1
-
// RUN: %clang_cc1 %s -verify -fsyntax-only -fdouble-square-bracket-attributes
1
+
// RUN: %clang_cc1 %s -verify -fsyntax-only --std=c2x
2
2
3
3
int f() [[deprecated]]; // expected-note 2 {{'f' has been explicitly marked deprecated here}}
4
4
void g() [[deprecated]];// expected-note {{'g' has been explicitly marked deprecated here}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1
-
// RUN: %clang_cc1 -fsyntax-only -Wunused -fdouble-square-bracket-attributes -verify %s
1
+
// RUN: %clang_cc1 -fsyntax-only -Wunused -std=c2x -verify %s
2
2
3
3
struct [[maybe_unused]] S1 { // ok
4
4
int a [[maybe_unused]];
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1
-
// RUN: %clang_cc1 -fsyntax-only -Wunused -fdouble-square-bracket-attributes -verify %s
1
+
// RUN: %clang_cc1 -fsyntax-only -Wunused -std=c2x -verify %s
2
2
3
3
struct [[maybe_unused]] S1 { // ok
4
4
int a [[maybe_unused]];
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4