Skip to content

Commit 61a57bc

Browse files
committed
Reject operator as a full declaration name, closes #846
1 parent c0ff5ac commit 61a57bc

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

regression-tests/test-results/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
cppfront compiler v0.3.0 Build 9104:1043
2+
cppfront compiler v0.3.0 Build 9104:1118
33
Copyright(c) Herb Sutter All rights reserved
44

55
SPDX-License-Identifier: CC-BY-NC-ND-4.0

source/build.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"9104:1043"
1+
"9104:1118"

source/sema.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,14 @@ class sema
10481048
auto check(declaration_node const& n)
10491049
-> bool
10501050
{
1051+
if (n.has_name("operator")) {
1052+
errors.emplace_back(
1053+
n.position(),
1054+
"the name 'operator' is incomplete - did you mean to write an overloaded operator name like 'operator*' or 'operator++'?"
1055+
);
1056+
return false;
1057+
}
1058+
10511059
// An object of deduced type must have an initializer
10521060
if (
10531061
n.is_object()

0 commit comments

Comments
 (0)