You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Turn -Wdeprecated-literal-operator on by default (#111027)
It would be nice to see what our users think about this change, as this
is something that WG21/EWG quite wants to fix a handful of questionable
issues with UB. Depending on the outcome of this after being committed,
we might instead suggest EWG undeprecate this, and require a bit of
'magic' from the lexer.
Additionally, this patch makes it so we emit this diagnostic ALSO in
cases where the literal name is reserved. It doesn't make sense to limit
that.
---------
Co-authored-by: Vlad Serebrennikov <[email protected]>
voidoperator"" wibble(constchar *); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
Copy file name to clipboardExpand all lines: clang/test/CXX/lex/lex.literal/lex.ext/p5.cpp
+4-4
Original file line number
Diff line number
Diff line change
@@ -3,19 +3,19 @@
3
3
4
4
usingsize_t = decltype(sizeof(int));
5
5
6
-
int &operator""_x1 (constchar *);
7
-
double &operator""_x1 (constchar *, size_t);
6
+
int &operator""_x1 (constchar *);
7
+
double &operator""_x1 (constchar *, size_t);
8
8
double &i1 = "foo"_x1;
9
9
#if __cplusplus >= 202002L
10
10
using char8 = float;
11
-
float &operator""_x1 (constchar8_t *, size_t);
11
+
float &operator""_x1 (constchar8_t *, size_t);
12
12
#else
13
13
using char8 = double;
14
14
#endif
15
15
char8 &i2 = u8"foo"_x1;
16
16
double &i3 = L"foo"_x1; // expected-error {{no matching literal operator for call to 'operator""_x1' with arguments of types 'const wchar_t *' and 'unsigned long'}}
Copy file name to clipboardExpand all lines: clang/test/CXX/over/over.oper/over.literal/p2.cpp
+14-14
Original file line number
Diff line number
Diff line change
@@ -1,43 +1,43 @@
1
1
// RUN: %clang_cc1 -std=c++11 %s -verify
2
2
3
-
voidoperator""_a(constchar *);
3
+
voidoperator""_a(constchar *);
4
4
5
5
namespaceN {
6
-
using ::operator""_a;
6
+
using ::operator""_a;
7
7
8
-
voidoperator""_b(constchar *);
8
+
voidoperator""_b(constchar *);
9
9
}
10
10
11
-
using N::operator""_b;
11
+
using N::operator""_b;
12
12
13
13
classC {
14
-
voidoperator""_c(constchar *); // expected-error {{must be in a namespace or global scope}}
14
+
voidoperator""_c(constchar *); // expected-error {{must be in a namespace or global scope}}
15
15
16
-
staticvoidoperator""_c(unsignedlonglong); // expected-error {{must be in a namespace or global scope}}
16
+
staticvoidoperator""_c(unsignedlonglong); // expected-error {{must be in a namespace or global scope}}
17
17
18
-
friendvoidoperator""_d(constchar *);
18
+
friendvoidoperator""_d(constchar *);
19
19
};
20
20
21
-
intoperator""_e; // expected-error {{cannot be the name of a variable}}
21
+
intoperator""_e; // expected-error {{cannot be the name of a variable}}
22
22
23
23
voidf() {
24
-
intoperator""_f; // expected-error {{cannot be the name of a variable}}
24
+
intoperator""_f; // expected-error {{cannot be the name of a variable}}
25
25
}
26
26
27
27
extern"C++" {
28
-
voidoperator""_g(constchar *);
28
+
voidoperator""_g(constchar *);
29
29
}
30
30
31
-
template<char...> voidoperator""_h() {}
31
+
template<char...> voidoperator""_h() {}
32
32
33
-
template<> voidoperator""_h<'a', 'b', 'c'>() {}
33
+
template<> voidoperator""_h<'a', 'b', 'c'>() {}
34
34
35
-
template voidoperator""_h<'a', 'b', 'c', 'd'>();
35
+
template voidoperator""_h<'a', 'b', 'c', 'd'>();
36
36
37
37
namespacerdar13605348 {
38
38
39
39
classC {
40
-
doubleoperator""_x(longdouble value) { returndouble(value); } // expected-error{{literal operator 'operator""_x' must be in a namespace or global scope}}
40
+
doubleoperator""_x(longdouble value) { returndouble(value); } // expected-error{{literal operator 'operator""_x' must be in a namespace or global scope}}
0 commit comments