diff options
author | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
commit | c72c57c9e9b69944e3e009cd5e209634839581d3 (patch) | |
tree | 4fc2f184c499d106f29a386c452b49e5197bf63d /lib/Sema/DeclSpec.cpp | |
parent | 5b20025c30d23d521e12c1f33ec8fa6b821952cd (diff) | |
download | FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.zip FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.tar.gz |
Vendor import of clang trunk r178860:
http://llvm.org/svn/llvm-project/cfe/trunk@178860
Diffstat (limited to 'lib/Sema/DeclSpec.cpp')
-rw-r--r-- | lib/Sema/DeclSpec.cpp | 84 |
1 files changed, 51 insertions, 33 deletions
diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index b3066eb..e1d55db 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -11,18 +11,18 @@ // //===----------------------------------------------------------------------===// -#include "clang/Parse/ParseDiagnostic.h" // FIXME: remove this back-dependency! #include "clang/Sema/DeclSpec.h" -#include "clang/Sema/LocInfoType.h" -#include "clang/Sema/ParsedTemplate.h" -#include "clang/Sema/SemaDiagnostic.h" -#include "clang/Sema/Sema.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Expr.h" #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/TypeLoc.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Basic/LangOptions.h" +#include "clang/Lex/Preprocessor.h" +#include "clang/Parse/ParseDiagnostic.h" // FIXME: remove this back-dependency! +#include "clang/Sema/LocInfoType.h" +#include "clang/Sema/ParsedTemplate.h" +#include "clang/Sema/Sema.h" +#include "clang/Sema/SemaDiagnostic.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorHandling.h" #include <cstring> @@ -169,6 +169,9 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType) { + assert(!(TypeQuals & DeclSpec::TQ_atomic) && + "function cannot have _Atomic qualifier"); + DeclaratorChunk I; I.Kind = Function; I.Loc = LocalRangeBegin; @@ -280,6 +283,14 @@ bool Declarator::isDeclarationOfFunction() const { case TST_unspecified: case TST_void: case TST_wchar: + case TST_image1d_t: + case TST_image1d_array_t: + case TST_image1d_buffer_t: + case TST_image2d_t: + case TST_image2d_array_t: + case TST_image3d_t: + case TST_sampler_t: + case TST_event_t: return false; case TST_decltype: @@ -323,7 +334,8 @@ unsigned DeclSpec::getParsedSpecifiers() const { if (hasTypeSpecifier()) Res |= PQ_TypeSpecifier; - if (FS_inline_specified || FS_virtual_specified || FS_explicit_specified) + if (FS_inline_specified || FS_virtual_specified || FS_explicit_specified || + FS_noreturn_specified) Res |= PQ_FunctionSpecifier; return Res; } @@ -414,6 +426,14 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T) { case DeclSpec::TST_underlyingType: return "__underlying_type"; case DeclSpec::TST_unknown_anytype: return "__unknown_anytype"; case DeclSpec::TST_atomic: return "_Atomic"; + case DeclSpec::TST_image1d_t: return "image1d_t"; + case DeclSpec::TST_image1d_array_t: return "image1d_array_t"; + case DeclSpec::TST_image1d_buffer_t: return "image1d_buffer_t"; + case DeclSpec::TST_image2d_t: return "image2d_t"; + case DeclSpec::TST_image2d_array_t: return "image2d_array_t"; + case DeclSpec::TST_image3d_t: return "image3d_t"; + case DeclSpec::TST_sampler_t: return "sampler_t"; + case DeclSpec::TST_event_t: return "event_t"; case DeclSpec::TST_error: return "(error)"; } llvm_unreachable("Unknown typespec!"); @@ -425,6 +445,7 @@ const char *DeclSpec::getSpecifierName(TQ T) { case DeclSpec::TQ_const: return "const"; case DeclSpec::TQ_restrict: return "restrict"; case DeclSpec::TQ_volatile: return "volatile"; + case DeclSpec::TQ_atomic: return "_Atomic"; } llvm_unreachable("Unknown typespec!"); } @@ -693,38 +714,44 @@ bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, TypeQualifiers |= T; switch (T) { - default: llvm_unreachable("Unknown type qualifier!"); - case TQ_const: TQ_constLoc = Loc; break; - case TQ_restrict: TQ_restrictLoc = Loc; break; - case TQ_volatile: TQ_volatileLoc = Loc; break; + case TQ_unspecified: break; + case TQ_const: TQ_constLoc = Loc; return false; + case TQ_restrict: TQ_restrictLoc = Loc; return false; + case TQ_volatile: TQ_volatileLoc = Loc; return false; + case TQ_atomic: TQ_atomicLoc = Loc; return false; } - return false; + + llvm_unreachable("Unknown type qualifier!"); } -bool DeclSpec::SetFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID) { +bool DeclSpec::setFunctionSpecInline(SourceLocation Loc) { // 'inline inline' is ok. FS_inline_specified = true; FS_inlineLoc = Loc; return false; } -bool DeclSpec::SetFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID) { +bool DeclSpec::setFunctionSpecVirtual(SourceLocation Loc) { // 'virtual virtual' is ok. FS_virtual_specified = true; FS_virtualLoc = Loc; return false; } -bool DeclSpec::SetFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID) { +bool DeclSpec::setFunctionSpecExplicit(SourceLocation Loc) { // 'explicit explicit' is ok. FS_explicit_specified = true; FS_explicitLoc = Loc; return false; } +bool DeclSpec::setFunctionSpecNoreturn(SourceLocation Loc) { + // '_Noreturn _Noreturn' is ok. + FS_noreturn_specified = true; + FS_noreturnLoc = Loc; + return false; +} + bool DeclSpec::SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID) { if (Friend_specified) { @@ -763,9 +790,10 @@ void DeclSpec::setProtocolQualifiers(Decl * const *Protos, SourceLocation *ProtoLocs, SourceLocation LAngleLoc) { if (NP == 0) return; - ProtocolQualifiers = new Decl*[NP]; + Decl **ProtoQuals = new Decl*[NP]; + memcpy(ProtoQuals, Protos, sizeof(Decl*)*NP); + ProtocolQualifiers = ProtoQuals; ProtocolLocs = new SourceLocation[NP]; - memcpy((void*)ProtocolQualifiers, Protos, sizeof(Decl*)*NP); memcpy(ProtocolLocs, ProtoLocs, sizeof(SourceLocation)*NP); NumProtocolQualifiers = NP; ProtocolLAngleLoc = LAngleLoc; @@ -787,15 +815,6 @@ void DeclSpec::SaveWrittenBuiltinSpecs() { } } -void DeclSpec::SaveStorageSpecifierAsWritten() { - if (SCS_extern_in_linkage_spec && StorageClassSpec == SCS_extern) - // If 'extern' is part of a linkage specification, - // then it is not a storage class "as written". - StorageClassSpecAsWritten = SCS_unspecified; - else - StorageClassSpecAsWritten = StorageClassSpec; -} - /// Finish - This does final analysis of the declspec, rejecting things like /// "_Imaginary" (lacking an FP type). This returns a diagnostic to issue or /// diag::NUM_DIAGNOSTICS if there is no error. After calling this method, @@ -803,7 +822,6 @@ void DeclSpec::SaveStorageSpecifierAsWritten() { void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP) { // Before possibly changing their values, save specs as written. SaveWrittenBuiltinSpecs(); - SaveStorageSpecifierAsWritten(); // Check the type specifier components first. @@ -913,15 +931,15 @@ void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP) { if (PP.getLangOpts().CPlusPlus && !PP.getLangOpts().MicrosoftExt && TypeSpecType == TST_unspecified && StorageClassSpec == SCS_auto) { TypeSpecType = TST_auto; - StorageClassSpec = StorageClassSpecAsWritten = SCS_unspecified; + StorageClassSpec = SCS_unspecified; TSTLoc = TSTNameLoc = StorageClassSpecLoc; StorageClassSpecLoc = SourceLocation(); } // Diagnose if we've recovered from an ill-formed 'auto' storage class // specifier in a pre-C++0x dialect of C++. - if (!PP.getLangOpts().CPlusPlus0x && TypeSpecType == TST_auto) + if (!PP.getLangOpts().CPlusPlus11 && TypeSpecType == TST_auto) Diag(D, TSTLoc, diag::ext_auto_type_specifier); - if (PP.getLangOpts().CPlusPlus && !PP.getLangOpts().CPlusPlus0x && + if (PP.getLangOpts().CPlusPlus && !PP.getLangOpts().CPlusPlus11 && StorageClassSpec == SCS_auto) Diag(D, StorageClassSpecLoc, diag::warn_auto_storage_class) << FixItHint::CreateRemoval(StorageClassSpecLoc); |