[cfe-commits] r163831 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/CXX/dcl.decl/dcl.meaning/p1.cpp test/CXX/temp/p3.cpp test/FixIt/fixit.cpp test/Misc/warning-flags.c test/SemaCXX/MicrosoftExtensions.cpp test/SemaCXX/class.cpp test/SemaCXX/nested-name-spec.cpp
Douglas Gregor
dgregor at apple.com
Thu Sep 13 13:16:21 PDT 2012
Author: dgregor
Date: Thu Sep 13 15:16:20 2012
New Revision: 163831
URL: http://llvm.org/viewvc/llvm-project?rev=163831&view=rev
Log:
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>.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp
cfe/trunk/test/CXX/temp/p3.cpp
cfe/trunk/test/FixIt/fixit.cpp
cfe/trunk/test/Misc/warning-flags.c
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
cfe/trunk/test/SemaCXX/class.cpp
cfe/trunk/test/SemaCXX/nested-name-spec.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=163831&r1=163830&r2=163831&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 13 15:16:20 2012
@@ -3954,6 +3954,8 @@
"out-of-line declaration of a member must be a definition">,
InGroup<OutOfLineDeclaration>, DefaultError;
def warn_member_extra_qualification : Warning<
+ "extra qualification on member %0">, InGroup<Microsoft>;
+def err_member_extra_qualification : Error<
"extra qualification on member %0">;
def err_member_qualification : Error<
"non-friend class member %0 cannot have a qualified name">;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=163831&r1=163830&r2=163831&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Sep 13 15:16:20 2012
@@ -3523,7 +3523,8 @@
// void X::f();
// };
if (Cur->Equals(DC)) {
- Diag(Loc, diag::warn_member_extra_qualification)
+ Diag(Loc, LangOpts.MicrosoftExt? diag::warn_member_extra_qualification
+ : diag::err_member_extra_qualification)
<< Name << FixItHint::CreateRemoval(SS.getRange());
SS.clear();
return false;
Modified: cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp?rev=163831&r1=163830&r2=163831&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp Thu Sep 13 15:16:20 2012
@@ -7,7 +7,7 @@
struct PR8019::x { int x; }; // expected-error{{non-friend class member 'x' cannot have a qualified name}}
struct inner;
- struct y::inner { }; // expected-warning{{extra qualification on member 'inner'}}
+ struct y::inner { }; // expected-error{{extra qualification on member 'inner'}}
template<typename T>
struct PR8019::x2 { }; // expected-error{{non-friend class member 'x2' cannot have a qualified name}}
@@ -16,7 +16,7 @@
struct inner_template;
template<typename T>
- struct y::inner_template { }; // expected-warning{{extra qualification on member 'inner_template'}}
+ struct y::inner_template { }; // expected-error{{extra qualification on member 'inner_template'}}
};
}
@@ -29,9 +29,9 @@
template<typename T> void wibble(T);
}
namespace NS {
- void NS::foo() {} // expected-warning{{extra qualification on member 'foo'}}
- int NS::bar; // expected-warning{{extra qualification on member 'bar'}}
- struct NS::X { }; // expected-warning{{extra qualification on member 'X'}}
- template<typename T> struct NS::Y; // expected-warning{{extra qualification on member 'Y'}}
- template<typename T> void NS::wibble(T) { } // expected-warning{{extra qualification on member 'wibble'}}
+ void NS::foo() {} // expected-error{{extra qualification on member 'foo'}}
+ int NS::bar; // expected-error{{extra qualification on member 'bar'}}
+ struct NS::X { }; // expected-error{{extra qualification on member 'X'}}
+ template<typename T> struct NS::Y; // expected-error{{extra qualification on member 'Y'}}
+ template<typename T> void NS::wibble(T) { } // expected-error{{extra qualification on member 'wibble'}}
}
Modified: cfe/trunk/test/CXX/temp/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/p3.cpp?rev=163831&r1=163830&r2=163831&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/p3.cpp (original)
+++ cfe/trunk/test/CXX/temp/p3.cpp Thu Sep 13 15:16:20 2012
@@ -8,7 +8,7 @@
template<typename T> struct A { static A a; } A<T>::a; // expected-error {{expected ';' after struct}} \
expected-error {{use of undeclared identifier 'T'}} \
- expected-warning{{extra qualification}}
+ expected-error{{extra qualification}}
template<typename T> struct B { } f(); // expected-error {{expected ';' after struct}} \
expected-error {{requires a type specifier}}
Modified: cfe/trunk/test/FixIt/fixit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.cpp?rev=163831&r1=163830&r2=163831&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/fixit.cpp (original)
+++ cfe/trunk/test/FixIt/fixit.cpp Thu Sep 13 15:16:20 2012
@@ -64,7 +64,7 @@
// extra qualification on member
class C {
- int C::foo(); // expected-warning {{extra qualification}}
+ int C::foo(); // expected-error {{extra qualification}}
};
namespace rdar8488464 {
Modified: cfe/trunk/test/Misc/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=163831&r1=163830&r2=163831&view=diff
==============================================================================
--- cfe/trunk/test/Misc/warning-flags.c (original)
+++ cfe/trunk/test/Misc/warning-flags.c Thu Sep 13 15:16:20 2012
@@ -18,7 +18,7 @@
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (159):
+CHECK: Warnings without flags (158):
CHECK-NEXT: ext_delete_void_ptr_operand
CHECK-NEXT: ext_enum_friend
CHECK-NEXT: ext_expected_semi_decl_list
@@ -101,7 +101,6 @@
CHECK-NEXT: warn_invalid_asm_cast_lvalue
CHECK-NEXT: warn_many_braces_around_scalar_init
CHECK-NEXT: warn_maynot_respond
-CHECK-NEXT: warn_member_extra_qualification
CHECK-NEXT: warn_method_param_redefinition
CHECK-NEXT: warn_mismatched_exception_spec
CHECK-NEXT: warn_missing_case_for_condition
Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=163831&r1=163830&r2=163831&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Thu Sep 13 15:16:20 2012
@@ -203,3 +203,4 @@
void f() { int __except = 0; }
+void ::f(); // expected-warning{{extra qualification on member 'f'}}
Modified: cfe/trunk/test/SemaCXX/class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/class.cpp?rev=163831&r1=163830&r2=163831&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/class.cpp (original)
+++ cfe/trunk/test/SemaCXX/class.cpp Thu Sep 13 15:16:20 2012
@@ -120,7 +120,7 @@
struct S
{
void f(); // expected-note 1 {{previous declaration}}
- void S::f() {} // expected-warning {{extra qualification on member}} expected-error {{class member cannot be redeclared}} expected-note {{previous declaration}} expected-note {{previous definition}}
+ void S::f() {} // expected-error {{extra qualification on member}} expected-error {{class member cannot be redeclared}} expected-note {{previous declaration}} expected-note {{previous definition}}
void f() {} // expected-error {{class member cannot be redeclared}} expected-error {{redefinition}}
};
Modified: cfe/trunk/test/SemaCXX/nested-name-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nested-name-spec.cpp?rev=163831&r1=163830&r2=163831&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/nested-name-spec.cpp (original)
+++ cfe/trunk/test/SemaCXX/nested-name-spec.cpp Thu Sep 13 15:16:20 2012
@@ -159,7 +159,7 @@
void f();
// FIXME: if we move this to a separate definition of N, things break!
}
-void ::global_func2(int) { } // expected-warning{{extra qualification on member 'global_func2'}}
+void ::global_func2(int) { } // expected-error{{extra qualification on member 'global_func2'}}
void N::f() { } // okay
@@ -245,15 +245,15 @@
}
class CLASS {
- void CLASS::foo2(); // expected-warning {{extra qualification on member 'foo2'}}
+ void CLASS::foo2(); // expected-error {{extra qualification on member 'foo2'}}
};
namespace PR8159 {
class B { };
class A {
- int A::a; // expected-warning{{extra qualification on member 'a'}}
- static int A::b; // expected-warning{{extra qualification on member 'b'}}
+ int A::a; // expected-error{{extra qualification on member 'a'}}
+ static int A::b; // expected-error{{extra qualification on member 'b'}}
int ::c; // expected-error{{non-friend class member 'c' cannot have a qualified name}}
};
}
More information about the cfe-commits
mailing list