r209635 - Rejecting the mutable specifier on a freestanding type declaration, instead of supporting it as a "extension" (which serves no purpose). Un-XFAILing the test for mutable specifiers.
Aaron Ballman
aaron at aaronballman.com
Mon May 26 10:03:55 PDT 2014
Author: aaronballman
Date: Mon May 26 12:03:54 2014
New Revision: 209635
URL: http://llvm.org/viewvc/llvm-project?rev=209635&view=rev
Log:
Rejecting the mutable specifier on a freestanding type declaration, instead of supporting it as a "extension" (which serves no purpose). Un-XFAILing the test for mutable specifiers.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=209635&r1=209634&r2=209635&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May 26 12:03:54 2014
@@ -3344,10 +3344,15 @@ Decl *Sema::ParsedFreeStandingDeclSpec(S
// Note that a linkage-specification sets a storage class, but
// 'extern "C" struct foo;' is actually valid and not theoretically
// useless.
- if (DeclSpec::SCS SCS = DS.getStorageClassSpec())
- if (!DS.isExternInLinkageSpec() && SCS != DeclSpec::SCS_typedef)
+ if (DeclSpec::SCS SCS = DS.getStorageClassSpec()) {
+ if (SCS == DeclSpec::SCS_mutable)
+ // Since mutable is not a viable storage class specifier in C, there is
+ // no reason to treat it as an extension. Instead, diagnose as an error.
+ Diag(DS.getStorageClassSpecLoc(), diag::err_mutable_nonmember);
+ else if (!DS.isExternInLinkageSpec() && SCS != DeclSpec::SCS_typedef)
Diag(DS.getStorageClassSpecLoc(), DiagID)
<< DeclSpec::getSpecifierName(SCS);
+ }
if (DeclSpec::TSCS TSCS = DS.getThreadStorageClassSpec())
Diag(DS.getThreadStorageClassSpecLoc(), DiagID)
Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp?rev=209635&r1=209634&r2=209635&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp Mon May 26 12:03:54 2014
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -verify %s
-// XFAIL: *
+// RUN: %clang_cc1 -fsyntax-only -verify %s
typedef const int T0;
typedef int& T1;
@@ -9,6 +8,6 @@ struct s0 {
mutable T0 f1; // expected-error{{'mutable' and 'const' cannot be mixed}}
mutable int &f2; // expected-error{{'mutable' cannot be applied to references}}
mutable T1 f3; // expected-error{{'mutable' cannot be applied to references}}
- mutable struct s1 {}; // expected-error{{'mutable' cannot be applied to non-data members}}
+ mutable struct s1 {}; // expected-error{{'mutable' can only be applied to member variables}}
mutable void im0(); // expected-error{{'mutable' cannot be applied to functions}}
};
More information about the cfe-commits
mailing list