Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 7537945

Browse files
committed
Promote the warning about extra qualification on a declaration from a
warning to an error. C++ bans it, and both GCC and EDG diagnose it as an error. Microsoft allows it, so we still warn in Microsoft mode. Fixes <rdar://problem/11135644>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163831 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent ceb0762 commit 7537945

File tree

9 files changed

+20
-17
lines changed

9 files changed

+20
-17
lines changed

include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,6 +3954,8 @@ def ext_out_of_line_declaration : ExtWarn<
39543954
"out-of-line declaration of a member must be a definition">,
39553955
InGroup<OutOfLineDeclaration>, DefaultError;
39563956
def warn_member_extra_qualification : Warning<
3957+
"extra qualification on member %0">, InGroup<Microsoft>;
3958+
def err_member_extra_qualification : Error<
39573959
"extra qualification on member %0">;
39583960
def err_member_qualification : Error<
39593961
"non-friend class member %0 cannot have a qualified name">;

lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3523,7 +3523,8 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC,
35233523
// void X::f();
35243524
// };
35253525
if (Cur->Equals(DC)) {
3526-
Diag(Loc, diag::warn_member_extra_qualification)
3526+
Diag(Loc, LangOpts.MicrosoftExt? diag::warn_member_extra_qualification
3527+
: diag::err_member_extra_qualification)
35273528
<< Name << FixItHint::CreateRemoval(SS.getRange());
35283529
SS.clear();
35293530
return false;

test/CXX/dcl.decl/dcl.meaning/p1.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace PR8019 {
77
struct PR8019::x { int x; }; // expected-error{{non-friend class member 'x' cannot have a qualified name}}
88

99
struct inner;
10-
struct y::inner { }; // expected-warning{{extra qualification on member 'inner'}}
10+
struct y::inner { }; // expected-error{{extra qualification on member 'inner'}}
1111

1212
template<typename T>
1313
struct PR8019::x2 { }; // expected-error{{non-friend class member 'x2' cannot have a qualified name}}
@@ -16,7 +16,7 @@ namespace PR8019 {
1616
struct inner_template;
1717

1818
template<typename T>
19-
struct y::inner_template { }; // expected-warning{{extra qualification on member 'inner_template'}}
19+
struct y::inner_template { }; // expected-error{{extra qualification on member 'inner_template'}}
2020
};
2121

2222
}
@@ -29,9 +29,9 @@ namespace NS {
2929
template<typename T> void wibble(T);
3030
}
3131
namespace NS {
32-
void NS::foo() {} // expected-warning{{extra qualification on member 'foo'}}
33-
int NS::bar; // expected-warning{{extra qualification on member 'bar'}}
34-
struct NS::X { }; // expected-warning{{extra qualification on member 'X'}}
35-
template<typename T> struct NS::Y; // expected-warning{{extra qualification on member 'Y'}}
36-
template<typename T> void NS::wibble(T) { } // expected-warning{{extra qualification on member 'wibble'}}
32+
void NS::foo() {} // expected-error{{extra qualification on member 'foo'}}
33+
int NS::bar; // expected-error{{extra qualification on member 'bar'}}
34+
struct NS::X { }; // expected-error{{extra qualification on member 'X'}}
35+
template<typename T> struct NS::Y; // expected-error{{extra qualification on member 'Y'}}
36+
template<typename T> void NS::wibble(T) { } // expected-error{{extra qualification on member 'wibble'}}
3737
}

test/CXX/temp/p3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ template<typename T> int S<T>::a, S<T>::b; // expected-error {{can only declare
88

99
template<typename T> struct A { static A a; } A<T>::a; // expected-error {{expected ';' after struct}} \
1010
expected-error {{use of undeclared identifier 'T'}} \
11-
expected-warning{{extra qualification}}
11+
expected-error{{extra qualification}}
1212

1313
template<typename T> struct B { } f(); // expected-error {{expected ';' after struct}} \
1414
expected-error {{requires a type specifier}}

test/FixIt/fixit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace rdar7796492 {
6464

6565
// extra qualification on member
6666
class C {
67-
int C::foo(); // expected-warning {{extra qualification}}
67+
int C::foo(); // expected-error {{extra qualification}}
6868
};
6969

7070
namespace rdar8488464 {

test/Misc/warning-flags.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This test serves two purposes:
1818

1919
The list of warnings below should NEVER grow. It should gradually shrink to 0.
2020

21-
CHECK: Warnings without flags (159):
21+
CHECK: Warnings without flags (158):
2222
CHECK-NEXT: ext_delete_void_ptr_operand
2323
CHECK-NEXT: ext_enum_friend
2424
CHECK-NEXT: ext_expected_semi_decl_list
@@ -101,7 +101,6 @@ CHECK-NEXT: warn_integer_too_large_for_signed
101101
CHECK-NEXT: warn_invalid_asm_cast_lvalue
102102
CHECK-NEXT: warn_many_braces_around_scalar_init
103103
CHECK-NEXT: warn_maynot_respond
104-
CHECK-NEXT: warn_member_extra_qualification
105104
CHECK-NEXT: warn_method_param_redefinition
106105
CHECK-NEXT: warn_mismatched_exception_spec
107106
CHECK-NEXT: warn_missing_case_for_condition

test/SemaCXX/MicrosoftExtensions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,4 @@ struct PR11150 {
203203

204204
void f() { int __except = 0; }
205205

206+
void ::f(); // expected-warning{{extra qualification on member 'f'}}

test/SemaCXX/class.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ struct C4 {
120120
struct S
121121
{
122122
void f(); // expected-note 1 {{previous declaration}}
123-
void S::f() {} // expected-warning {{extra qualification on member}} expected-error {{class member cannot be redeclared}} expected-note {{previous declaration}} expected-note {{previous definition}}
123+
void S::f() {} // expected-error {{extra qualification on member}} expected-error {{class member cannot be redeclared}} expected-note {{previous declaration}} expected-note {{previous definition}}
124124
void f() {} // expected-error {{class member cannot be redeclared}} expected-error {{redefinition}}
125125
};
126126

test/SemaCXX/nested-name-spec.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ namespace N {
159159
void f();
160160
// FIXME: if we move this to a separate definition of N, things break!
161161
}
162-
void ::global_func2(int) { } // expected-warning{{extra qualification on member 'global_func2'}}
162+
void ::global_func2(int) { } // expected-error{{extra qualification on member 'global_func2'}}
163163

164164
void N::f() { } // okay
165165

@@ -245,15 +245,15 @@ namespace PR7133 {
245245
}
246246

247247
class CLASS {
248-
void CLASS::foo2(); // expected-warning {{extra qualification on member 'foo2'}}
248+
void CLASS::foo2(); // expected-error {{extra qualification on member 'foo2'}}
249249
};
250250

251251
namespace PR8159 {
252252
class B { };
253253

254254
class A {
255-
int A::a; // expected-warning{{extra qualification on member 'a'}}
256-
static int A::b; // expected-warning{{extra qualification on member 'b'}}
255+
int A::a; // expected-error{{extra qualification on member 'a'}}
256+
static int A::b; // expected-error{{extra qualification on member 'b'}}
257257
int ::c; // expected-error{{non-friend class member 'c' cannot have a qualified name}}
258258
};
259259
}

0 commit comments

Comments
 (0)