forked from OSchip/llvm-project
Fix for PR9812: warn about bool instead of _Bool.
llvm-svn: 199311
This commit is contained in:
parent
da3b5987ca
commit
888d52a655
|
@ -508,7 +508,8 @@ public:
|
|||
bool hasTagDefinition() const;
|
||||
|
||||
/// \brief Turn a type-specifier-type into a string like "_Bool" or "union".
|
||||
static const char *getSpecifierName(DeclSpec::TST T);
|
||||
static const char *getSpecifierName(DeclSpec::TST T,
|
||||
const PrintingPolicy &Policy);
|
||||
static const char *getSpecifierName(DeclSpec::TQ Q);
|
||||
static const char *getSpecifierName(DeclSpec::TSS S);
|
||||
static const char *getSpecifierName(DeclSpec::TSC C);
|
||||
|
@ -596,36 +597,45 @@ public:
|
|||
/// TODO: use a more general approach that still allows these
|
||||
/// diagnostics to be ignored when desired.
|
||||
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc,
|
||||
const char *&PrevSpec, unsigned &DiagID);
|
||||
const char *&PrevSpec, unsigned &DiagID,
|
||||
const PrintingPolicy &Policy);
|
||||
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc,
|
||||
const char *&PrevSpec, unsigned &DiagID);
|
||||
bool SetTypeSpecWidth(TSW W, SourceLocation Loc, const char *&PrevSpec,
|
||||
unsigned &DiagID);
|
||||
unsigned &DiagID, const PrintingPolicy &Policy);
|
||||
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec,
|
||||
unsigned &DiagID);
|
||||
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec,
|
||||
unsigned &DiagID);
|
||||
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
|
||||
unsigned &DiagID);
|
||||
unsigned &DiagID, const PrintingPolicy &Policy);
|
||||
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
|
||||
unsigned &DiagID, ParsedType Rep);
|
||||
unsigned &DiagID, ParsedType Rep,
|
||||
const PrintingPolicy &Policy);
|
||||
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
|
||||
unsigned &DiagID, Decl *Rep, bool Owned);
|
||||
unsigned &DiagID, Decl *Rep, bool Owned,
|
||||
const PrintingPolicy &Policy);
|
||||
bool SetTypeSpecType(TST T, SourceLocation TagKwLoc,
|
||||
SourceLocation TagNameLoc, const char *&PrevSpec,
|
||||
unsigned &DiagID, ParsedType Rep);
|
||||
unsigned &DiagID, ParsedType Rep,
|
||||
const PrintingPolicy &Policy);
|
||||
bool SetTypeSpecType(TST T, SourceLocation TagKwLoc,
|
||||
SourceLocation TagNameLoc, const char *&PrevSpec,
|
||||
unsigned &DiagID, Decl *Rep, bool Owned);
|
||||
unsigned &DiagID, Decl *Rep, bool Owned,
|
||||
const PrintingPolicy &Policy);
|
||||
|
||||
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
|
||||
unsigned &DiagID, Expr *Rep);
|
||||
unsigned &DiagID, Expr *Rep,
|
||||
const PrintingPolicy &policy);
|
||||
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
|
||||
const char *&PrevSpec, unsigned &DiagID);
|
||||
const char *&PrevSpec, unsigned &DiagID,
|
||||
const PrintingPolicy &Policy);
|
||||
bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
|
||||
const char *&PrevSpec, unsigned &DiagID);
|
||||
const char *&PrevSpec, unsigned &DiagID,
|
||||
const PrintingPolicy &Policy);
|
||||
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc,
|
||||
const char *&PrevSpec, unsigned &DiagID);
|
||||
const char *&PrevSpec, unsigned &DiagID,
|
||||
const PrintingPolicy &Policy);
|
||||
bool SetTypeSpecError();
|
||||
void UpdateDeclRep(Decl *Rep) {
|
||||
assert(isDeclRep((TST) TypeSpecType));
|
||||
|
@ -735,7 +745,8 @@ public:
|
|||
/// Finish - This does final analysis of the declspec, issuing diagnostics for
|
||||
/// things like "_Imaginary" (lacking an FP type). After calling this method,
|
||||
/// DeclSpec is guaranteed self-consistent, even if an error occurred.
|
||||
void Finish(DiagnosticsEngine &D, Preprocessor &PP);
|
||||
void Finish(DiagnosticsEngine &D, Preprocessor &PP,
|
||||
const PrintingPolicy &Policy);
|
||||
|
||||
const WrittenBuiltinSpecs& getWrittenBuiltinSpecs() const {
|
||||
return writtenBS;
|
||||
|
|
|
@ -1641,7 +1641,8 @@ public:
|
|||
|
||||
Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
|
||||
AccessSpecifier AS,
|
||||
RecordDecl *Record);
|
||||
RecordDecl *Record,
|
||||
const PrintingPolicy &Policy);
|
||||
|
||||
Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
|
||||
RecordDecl *Record);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "clang/Parse/Parser.h"
|
||||
#include "RAIIObjectsForParser.h"
|
||||
#include "clang/AST/DeclTemplate.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/Basic/AddressSpaces.h"
|
||||
#include "clang/Basic/CharInfo.h"
|
||||
#include "clang/Parse/ParseDiagnostic.h"
|
||||
|
@ -2218,7 +2219,8 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
|
|||
// name token, and we're done.
|
||||
const char *PrevSpec;
|
||||
unsigned DiagID;
|
||||
DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T,
|
||||
Actions.getASTContext().getPrintingPolicy());
|
||||
DS.SetRangeEnd(Tok.getLocation());
|
||||
ConsumeToken();
|
||||
// There may be other declaration specifiers after this.
|
||||
|
@ -2422,9 +2424,10 @@ Parser::DiagnoseMissingSemiAfterTagDefinition(DeclSpec &DS, AccessSpecifier AS,
|
|||
if (MightBeDeclarator)
|
||||
return false;
|
||||
|
||||
const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
|
||||
Diag(PP.getLocForEndOfToken(DS.getRepAsDecl()->getLocEnd()),
|
||||
diag::err_expected_after)
|
||||
<< DeclSpec::getSpecifierName(DS.getTypeSpecType()) << tok::semi;
|
||||
<< DeclSpec::getSpecifierName(DS.getTypeSpecType(), PPol) << tok::semi;
|
||||
|
||||
// Try to recover from the typo, by dropping the tag definition and parsing
|
||||
// the problematic tokens as a type.
|
||||
|
@ -2480,6 +2483,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
bool EnteringContext = (DSContext == DSC_class || DSContext == DSC_top_level);
|
||||
bool AttrsLastTime = false;
|
||||
ParsedAttributesWithRange attrs(AttrFactory);
|
||||
const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
|
||||
while (1) {
|
||||
bool isInvalid = false;
|
||||
const char *PrevSpec = 0;
|
||||
|
@ -2503,7 +2507,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
|
||||
// If this is not a declaration specifier token, we're done reading decl
|
||||
// specifiers. First verify that DeclSpec's are consistent.
|
||||
DS.Finish(Diags, PP);
|
||||
DS.Finish(Diags, PP, Policy);
|
||||
return;
|
||||
|
||||
case tok::l_square:
|
||||
|
@ -2637,7 +2641,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
ParsedType T = getTypeAnnotation(Tok);
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename,
|
||||
Tok.getAnnotationEndLoc(),
|
||||
PrevSpec, DiagID, T);
|
||||
PrevSpec, DiagID, T, Policy);
|
||||
if (isInvalid)
|
||||
break;
|
||||
}
|
||||
|
@ -2696,7 +2700,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
ConsumeToken(); // The C++ scope.
|
||||
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec,
|
||||
DiagID, TypeRep);
|
||||
DiagID, TypeRep, Policy);
|
||||
if (isInvalid)
|
||||
break;
|
||||
|
||||
|
@ -2715,7 +2719,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
if (Tok.getAnnotationValue()) {
|
||||
ParsedType T = getTypeAnnotation(Tok);
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec,
|
||||
DiagID, T);
|
||||
DiagID, T, Policy);
|
||||
} else
|
||||
DS.SetTypeSpecError();
|
||||
|
||||
|
@ -2806,7 +2810,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
goto DoneWithDeclSpec;
|
||||
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec,
|
||||
DiagID, TypeRep);
|
||||
DiagID, TypeRep, Policy);
|
||||
if (isInvalid)
|
||||
break;
|
||||
|
||||
|
@ -2893,46 +2897,46 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
// storage-class-specifier
|
||||
case tok::kw_typedef:
|
||||
isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_typedef, Loc,
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_extern:
|
||||
if (DS.getThreadStorageClassSpec() == DeclSpec::TSCS___thread)
|
||||
Diag(Tok, diag::ext_thread_before) << "extern";
|
||||
isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_extern, Loc,
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw___private_extern__:
|
||||
isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_private_extern,
|
||||
Loc, PrevSpec, DiagID);
|
||||
Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_static:
|
||||
if (DS.getThreadStorageClassSpec() == DeclSpec::TSCS___thread)
|
||||
Diag(Tok, diag::ext_thread_before) << "static";
|
||||
isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_static, Loc,
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_auto:
|
||||
if (getLangOpts().CPlusPlus11) {
|
||||
if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
|
||||
isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_auto, Loc,
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Policy);
|
||||
if (!isInvalid)
|
||||
Diag(Tok, diag::ext_auto_storage_class)
|
||||
<< FixItHint::CreateRemoval(DS.getStorageClassSpecLoc());
|
||||
} else
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_auto, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
} else
|
||||
isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_auto, Loc,
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_register:
|
||||
isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_register, Loc,
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_mutable:
|
||||
isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_mutable, Loc,
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw___thread:
|
||||
isInvalid = DS.SetStorageClassSpecThread(DeclSpec::TSCS___thread, Loc,
|
||||
|
@ -2994,19 +2998,19 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
// type-specifier
|
||||
case tok::kw_short:
|
||||
isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_short, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_long:
|
||||
if (DS.getTypeSpecWidth() != DeclSpec::TSW_long)
|
||||
isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_long, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
else
|
||||
isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_longlong, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw___int64:
|
||||
isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_longlong, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_signed:
|
||||
isInvalid = DS.SetTypeSpecSign(DeclSpec::TSS_signed, Loc, PrevSpec,
|
||||
|
@ -3026,43 +3030,43 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
break;
|
||||
case tok::kw_void:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_void, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_char:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_char, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_int:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw___int128:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_half:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_half, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_float:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_float, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_double:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_double, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_wchar_t:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_wchar, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_char16_t:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_char16, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_char32_t:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_char32, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_bool:
|
||||
case tok::kw__Bool:
|
||||
|
@ -3076,30 +3080,30 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
isInvalid = true;
|
||||
} else {
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_bool, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
}
|
||||
break;
|
||||
case tok::kw__Decimal32:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_decimal32, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw__Decimal64:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_decimal64, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw__Decimal128:
|
||||
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_decimal128, Loc, PrevSpec,
|
||||
DiagID);
|
||||
DiagID, Policy);
|
||||
break;
|
||||
case tok::kw___vector:
|
||||
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID);
|
||||
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw___pixel:
|
||||
isInvalid = DS.SetTypeAltiVecPixel(true, Loc, PrevSpec, DiagID);
|
||||
isInvalid = DS.SetTypeAltiVecPixel(true, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw___unknown_anytype:
|
||||
isInvalid = DS.SetTypeSpecType(TST_unknown_anytype, Loc,
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
|
||||
// class-specifier:
|
||||
|
@ -3759,7 +3763,8 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
|
|||
|
||||
if (DS.SetTypeSpecType(DeclSpec::TST_typename, StartLoc,
|
||||
NameLoc.isValid() ? NameLoc : StartLoc,
|
||||
PrevSpec, DiagID, Type.get()))
|
||||
PrevSpec, DiagID, Type.get(),
|
||||
Actions.getASTContext().getPrintingPolicy()))
|
||||
Diag(StartLoc, DiagID) << PrevSpec;
|
||||
|
||||
return;
|
||||
|
@ -3782,7 +3787,8 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
|
|||
|
||||
if (DS.SetTypeSpecType(DeclSpec::TST_enum, StartLoc,
|
||||
NameLoc.isValid() ? NameLoc : StartLoc,
|
||||
PrevSpec, DiagID, TagDecl, Owned))
|
||||
PrevSpec, DiagID, TagDecl, Owned,
|
||||
Actions.getASTContext().getPrintingPolicy()))
|
||||
Diag(StartLoc, DiagID) << PrevSpec;
|
||||
}
|
||||
|
||||
|
@ -4464,7 +4470,7 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS,
|
|||
DoneWithTypeQuals:
|
||||
// If this is not a type-qualifier token, we're done reading type
|
||||
// qualifiers. First verify that DeclSpec's are consistent.
|
||||
DS.Finish(Diags, PP);
|
||||
DS.Finish(Diags, PP, Actions.getASTContext().getPrintingPolicy());
|
||||
if (EndLoc.isValid())
|
||||
DS.SetRangeEnd(EndLoc);
|
||||
return;
|
||||
|
@ -5619,7 +5625,8 @@ void Parser::ParseTypeofSpecifier(DeclSpec &DS) {
|
|||
unsigned DiagID;
|
||||
// Check for duplicate type specifiers (e.g. "int typeof(int)").
|
||||
if (DS.SetTypeSpecType(DeclSpec::TST_typeofType, StartLoc, PrevSpec,
|
||||
DiagID, CastTy))
|
||||
DiagID, CastTy,
|
||||
Actions.getASTContext().getPrintingPolicy()))
|
||||
Diag(StartLoc, DiagID) << PrevSpec;
|
||||
return;
|
||||
}
|
||||
|
@ -5641,7 +5648,8 @@ void Parser::ParseTypeofSpecifier(DeclSpec &DS) {
|
|||
unsigned DiagID;
|
||||
// Check for duplicate type specifiers (e.g. "int typeof(int)").
|
||||
if (DS.SetTypeSpecType(DeclSpec::TST_typeofExpr, StartLoc, PrevSpec,
|
||||
DiagID, Operand.get()))
|
||||
DiagID, Operand.get(),
|
||||
Actions.getASTContext().getPrintingPolicy()))
|
||||
Diag(StartLoc, DiagID) << PrevSpec;
|
||||
}
|
||||
|
||||
|
@ -5675,7 +5683,8 @@ void Parser::ParseAtomicSpecifier(DeclSpec &DS) {
|
|||
const char *PrevSpec = 0;
|
||||
unsigned DiagID;
|
||||
if (DS.SetTypeSpecType(DeclSpec::TST_atomic, StartLoc, PrevSpec,
|
||||
DiagID, Result.release()))
|
||||
DiagID, Result.release(),
|
||||
Actions.getASTContext().getPrintingPolicy()))
|
||||
Diag(StartLoc, DiagID) << PrevSpec;
|
||||
}
|
||||
|
||||
|
@ -5715,6 +5724,7 @@ bool Parser::TryAltiVecVectorTokenOutOfLine() {
|
|||
bool Parser::TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
|
||||
const char *&PrevSpec, unsigned &DiagID,
|
||||
bool &isInvalid) {
|
||||
const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
|
||||
if (Tok.getIdentifierInfo() == Ident_vector) {
|
||||
Token Next = NextToken();
|
||||
switch (Next.getKind()) {
|
||||
|
@ -5729,15 +5739,15 @@ bool Parser::TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
|
|||
case tok::kw_double:
|
||||
case tok::kw_bool:
|
||||
case tok::kw___pixel:
|
||||
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID);
|
||||
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy);
|
||||
return true;
|
||||
case tok::identifier:
|
||||
if (Next.getIdentifierInfo() == Ident_pixel) {
|
||||
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID);
|
||||
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID,Policy);
|
||||
return true;
|
||||
}
|
||||
if (Next.getIdentifierInfo() == Ident_bool) {
|
||||
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID);
|
||||
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID,Policy);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
@ -5746,11 +5756,11 @@ bool Parser::TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
|
|||
}
|
||||
} else if ((Tok.getIdentifierInfo() == Ident_pixel) &&
|
||||
DS.isTypeAltiVecVector()) {
|
||||
isInvalid = DS.SetTypeAltiVecPixel(true, Loc, PrevSpec, DiagID);
|
||||
isInvalid = DS.SetTypeAltiVecPixel(true, Loc, PrevSpec, DiagID, Policy);
|
||||
return true;
|
||||
} else if ((Tok.getIdentifierInfo() == Ident_bool) &&
|
||||
DS.isTypeAltiVecVector()) {
|
||||
isInvalid = DS.SetTypeAltiVecBool(true, Loc, PrevSpec, DiagID);
|
||||
isInvalid = DS.SetTypeAltiVecBool(true, Loc, PrevSpec, DiagID, Policy);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "clang/Parse/Parser.h"
|
||||
#include "RAIIObjectsForParser.h"
|
||||
#include "clang/AST/DeclTemplate.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/Basic/CharInfo.h"
|
||||
#include "clang/Basic/OperatorKinds.h"
|
||||
#include "clang/Parse/ParseDiagnostic.h"
|
||||
|
@ -786,12 +787,13 @@ SourceLocation Parser::ParseDecltypeSpecifier(DeclSpec &DS) {
|
|||
|
||||
const char *PrevSpec = 0;
|
||||
unsigned DiagID;
|
||||
const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
|
||||
// Check for duplicate type specifiers (e.g. "int decltype(a)").
|
||||
if (Result.get()
|
||||
? DS.SetTypeSpecType(DeclSpec::TST_decltype, StartLoc, PrevSpec,
|
||||
DiagID, Result.release())
|
||||
DiagID, Result.release(), Policy)
|
||||
: DS.SetTypeSpecType(DeclSpec::TST_decltype_auto, StartLoc, PrevSpec,
|
||||
DiagID)) {
|
||||
DiagID, Policy)) {
|
||||
Diag(StartLoc, DiagID) << PrevSpec;
|
||||
DS.SetTypeSpecError();
|
||||
}
|
||||
|
@ -842,7 +844,8 @@ void Parser::ParseUnderlyingTypeSpecifier(DeclSpec &DS) {
|
|||
const char *PrevSpec = 0;
|
||||
unsigned DiagID;
|
||||
if (DS.SetTypeSpecType(DeclSpec::TST_underlyingType, StartLoc, PrevSpec,
|
||||
DiagID, Result.release()))
|
||||
DiagID, Result.release(),
|
||||
Actions.getASTContext().getPrintingPolicy()))
|
||||
Diag(StartLoc, DiagID) << PrevSpec;
|
||||
DS.setTypeofParensRange(T.getRange());
|
||||
}
|
||||
|
@ -990,7 +993,8 @@ Parser::TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
|
|||
|
||||
const char *PrevSpec = 0;
|
||||
unsigned DiagID;
|
||||
DS.SetTypeSpecType(TST_typename, IdLoc, PrevSpec, DiagID, Type);
|
||||
DS.SetTypeSpecType(TST_typename, IdLoc, PrevSpec, DiagID, Type,
|
||||
Actions.getASTContext().getPrintingPolicy());
|
||||
|
||||
Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);
|
||||
return Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
|
||||
|
@ -1311,6 +1315,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
|
|||
// If there are attributes after class name, parse them.
|
||||
MaybeParseCXX11Attributes(Attributes);
|
||||
|
||||
const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
|
||||
Sema::TagUseKind TUK;
|
||||
if (DSC == DSC_trailing)
|
||||
TUK = Sema::TUK_Reference;
|
||||
|
@ -1368,9 +1373,10 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
|
|||
(Tok.isAtStartOfLine() && !isValidAfterTypeSpecifier(false)))) {
|
||||
TUK = DS.isFriendSpecified() ? Sema::TUK_Friend : Sema::TUK_Declaration;
|
||||
if (Tok.isNot(tok::semi)) {
|
||||
const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
|
||||
// A semicolon was missing after this declaration. Diagnose and recover.
|
||||
ExpectAndConsume(tok::semi, diag::err_expected_after,
|
||||
DeclSpec::getSpecifierName(TagType));
|
||||
DeclSpec::getSpecifierName(TagType, PPol));
|
||||
PP.EnterToken(Tok);
|
||||
Tok.setKind(tok::semi);
|
||||
}
|
||||
|
@ -1412,7 +1418,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
|
|||
if (DS.getTypeSpecType() != DeclSpec::TST_error) {
|
||||
// We have a declaration or reference to an anonymous class.
|
||||
Diag(StartLoc, diag::err_anon_type_definition)
|
||||
<< DeclSpec::getSpecifierName(TagType);
|
||||
<< DeclSpec::getSpecifierName(TagType, Policy);
|
||||
}
|
||||
|
||||
// If we are parsing a definition and stop at a base-clause, continue on
|
||||
|
@ -1609,11 +1615,12 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
|
|||
if (!TypeResult.isInvalid()) {
|
||||
Result = DS.SetTypeSpecType(DeclSpec::TST_typename, StartLoc,
|
||||
NameLoc.isValid() ? NameLoc : StartLoc,
|
||||
PrevSpec, DiagID, TypeResult.get());
|
||||
PrevSpec, DiagID, TypeResult.get(), Policy);
|
||||
} else if (!TagOrTempResult.isInvalid()) {
|
||||
Result = DS.SetTypeSpecType(TagType, StartLoc,
|
||||
NameLoc.isValid() ? NameLoc : StartLoc,
|
||||
PrevSpec, DiagID, TagOrTempResult.get(), Owned);
|
||||
PrevSpec, DiagID, TagOrTempResult.get(), Owned,
|
||||
Policy);
|
||||
} else {
|
||||
DS.SetTypeSpecError();
|
||||
return;
|
||||
|
@ -1634,8 +1641,9 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
|
|||
if (TUK == Sema::TUK_Definition &&
|
||||
(TemplateInfo.Kind || !isValidAfterTypeSpecifier(false))) {
|
||||
if (Tok.isNot(tok::semi)) {
|
||||
const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
|
||||
ExpectAndConsume(tok::semi, diag::err_expected_after,
|
||||
DeclSpec::getSpecifierName(TagType));
|
||||
DeclSpec::getSpecifierName(TagType, PPol));
|
||||
// Push this token back into the preprocessor and change our current token
|
||||
// to ';' so that the rest of the code recovers as though there were an
|
||||
// ';' after the definition.
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "clang/Sema/TypoCorrection.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
using namespace clang;
|
||||
|
||||
/// \brief Simple precedence-based parser for binary/ternary operators.
|
||||
|
@ -790,7 +791,8 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
|
|||
DS.SetRangeEnd(ILoc);
|
||||
const char *PrevSpec = 0;
|
||||
unsigned DiagID;
|
||||
DS.SetTypeSpecType(TST_typename, ILoc, PrevSpec, DiagID, Typ);
|
||||
DS.SetTypeSpecType(TST_typename, ILoc, PrevSpec, DiagID, Typ,
|
||||
Actions.getASTContext().getPrintingPolicy());
|
||||
|
||||
Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);
|
||||
TypeResult Ty = Actions.ActOnTypeName(getCurScope(),
|
||||
|
@ -955,7 +957,8 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
|
|||
const char *PrevSpec = 0;
|
||||
unsigned DiagID;
|
||||
DS.SetTypeSpecType(TST_typename, Tok.getAnnotationEndLoc(),
|
||||
PrevSpec, DiagID, Type);
|
||||
PrevSpec, DiagID, Type,
|
||||
Actions.getASTContext().getPrintingPolicy());
|
||||
|
||||
Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);
|
||||
TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
// This file implements the Expression parsing implementation for C++.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/DeclTemplate.h"
|
||||
#include "RAIIObjectsForParser.h"
|
||||
#include "clang/Basic/PrettyStackTrace.h"
|
||||
|
@ -1671,6 +1672,8 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
|
|||
const char *PrevSpec;
|
||||
unsigned DiagID;
|
||||
SourceLocation Loc = Tok.getLocation();
|
||||
const clang::PrintingPolicy &Policy =
|
||||
Actions.getASTContext().getPrintingPolicy();
|
||||
|
||||
switch (Tok.getKind()) {
|
||||
case tok::identifier: // foo::bar
|
||||
|
@ -1683,7 +1686,7 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
|
|||
case tok::annot_typename: {
|
||||
if (getTypeAnnotation(Tok))
|
||||
DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID,
|
||||
getTypeAnnotation(Tok));
|
||||
getTypeAnnotation(Tok), Policy);
|
||||
else
|
||||
DS.SetTypeSpecError();
|
||||
|
||||
|
@ -1697,19 +1700,19 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
|
|||
if (Tok.is(tok::less) && getLangOpts().ObjC1)
|
||||
ParseObjCProtocolQualifiers(DS);
|
||||
|
||||
DS.Finish(Diags, PP);
|
||||
DS.Finish(Diags, PP, Policy);
|
||||
return;
|
||||
}
|
||||
|
||||
// builtin types
|
||||
case tok::kw_short:
|
||||
DS.SetTypeSpecWidth(DeclSpec::TSW_short, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecWidth(DeclSpec::TSW_short, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_long:
|
||||
DS.SetTypeSpecWidth(DeclSpec::TSW_long, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecWidth(DeclSpec::TSW_long, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw___int64:
|
||||
DS.SetTypeSpecWidth(DeclSpec::TSW_longlong, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecWidth(DeclSpec::TSW_longlong, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_signed:
|
||||
DS.SetTypeSpecSign(DeclSpec::TSS_signed, Loc, PrevSpec, DiagID);
|
||||
|
@ -1718,47 +1721,47 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
|
|||
DS.SetTypeSpecSign(DeclSpec::TSS_unsigned, Loc, PrevSpec, DiagID);
|
||||
break;
|
||||
case tok::kw_void:
|
||||
DS.SetTypeSpecType(DeclSpec::TST_void, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_void, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_char:
|
||||
DS.SetTypeSpecType(DeclSpec::TST_char, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_char, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_int:
|
||||
DS.SetTypeSpecType(DeclSpec::TST_int, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_int, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw___int128:
|
||||
DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_half:
|
||||
DS.SetTypeSpecType(DeclSpec::TST_half, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_half, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_float:
|
||||
DS.SetTypeSpecType(DeclSpec::TST_float, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_float, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_double:
|
||||
DS.SetTypeSpecType(DeclSpec::TST_double, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_double, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_wchar_t:
|
||||
DS.SetTypeSpecType(DeclSpec::TST_wchar, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_wchar, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_char16_t:
|
||||
DS.SetTypeSpecType(DeclSpec::TST_char16, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_char16, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_char32_t:
|
||||
DS.SetTypeSpecType(DeclSpec::TST_char32, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_char32, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::kw_bool:
|
||||
DS.SetTypeSpecType(DeclSpec::TST_bool, Loc, PrevSpec, DiagID);
|
||||
DS.SetTypeSpecType(DeclSpec::TST_bool, Loc, PrevSpec, DiagID, Policy);
|
||||
break;
|
||||
case tok::annot_decltype:
|
||||
case tok::kw_decltype:
|
||||
DS.SetRangeEnd(ParseDecltypeSpecifier(DS));
|
||||
return DS.Finish(Diags, PP);
|
||||
return DS.Finish(Diags, PP, Policy);
|
||||
|
||||
// GNU typeof support.
|
||||
case tok::kw_typeof:
|
||||
ParseTypeofSpecifier(DS);
|
||||
DS.Finish(Diags, PP);
|
||||
DS.Finish(Diags, PP, Policy);
|
||||
return;
|
||||
}
|
||||
if (Tok.is(tok::annot_typename))
|
||||
|
@ -1766,7 +1769,7 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
|
|||
else
|
||||
DS.SetRangeEnd(Tok.getLocation());
|
||||
ConsumeToken();
|
||||
DS.Finish(Diags, PP);
|
||||
DS.Finish(Diags, PP, Policy);
|
||||
}
|
||||
|
||||
/// ParseCXXTypeSpecifierSeq - Parse a C++ type-specifier-seq (C++
|
||||
|
@ -1782,7 +1785,7 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
|
|||
///
|
||||
bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) {
|
||||
ParseSpecifierQualifierList(DS, AS_none, DSC_type_specifier);
|
||||
DS.Finish(Diags, PP);
|
||||
DS.Finish(Diags, PP, Actions.getASTContext().getPrintingPolicy());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "ParsePragma.h"
|
||||
#include "RAIIObjectsForParser.h"
|
||||
#include "clang/AST/ASTConsumer.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/DeclTemplate.h"
|
||||
#include "clang/Parse/ParseDiagnostic.h"
|
||||
#include "clang/Sema/DeclSpec.h"
|
||||
|
@ -246,7 +247,8 @@ void Parser::ConsumeExtraSemi(ExtraSemiKind Kind, unsigned TST) {
|
|||
|
||||
if (Kind != AfterMemberFunctionDefinition || HadMultipleSemis)
|
||||
Diag(StartLoc, diag::ext_extra_semi)
|
||||
<< Kind << DeclSpec::getSpecifierName((DeclSpec::TST)TST)
|
||||
<< Kind << DeclSpec::getSpecifierName((DeclSpec::TST)TST,
|
||||
Actions.getASTContext().getPrintingPolicy())
|
||||
<< FixItHint::CreateRemoval(SourceRange(StartLoc, EndLoc));
|
||||
else
|
||||
// A single semicolon is valid after a member function definition.
|
||||
|
@ -930,7 +932,8 @@ Parser::ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs,
|
|||
|
||||
const char *PrevSpec = 0;
|
||||
unsigned DiagID;
|
||||
if (DS.SetTypeSpecType(DeclSpec::TST_unspecified, AtLoc, PrevSpec, DiagID))
|
||||
if (DS.SetTypeSpecType(DeclSpec::TST_unspecified, AtLoc, PrevSpec, DiagID,
|
||||
Actions.getASTContext().getPrintingPolicy()))
|
||||
Diag(AtLoc, DiagID) << PrevSpec;
|
||||
|
||||
if (Tok.isObjCAtKeyword(tok::objc_protocol))
|
||||
|
@ -1017,9 +1020,11 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D,
|
|||
if (getLangOpts().ImplicitInt && D.getDeclSpec().isEmpty()) {
|
||||
const char *PrevSpec;
|
||||
unsigned DiagID;
|
||||
const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
|
||||
D.getMutableDeclSpec().SetTypeSpecType(DeclSpec::TST_int,
|
||||
D.getIdentifierLoc(),
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID,
|
||||
Policy);
|
||||
D.SetRangeBegin(D.getDeclSpec().getSourceRange().getBegin());
|
||||
}
|
||||
|
||||
|
|
|
@ -418,12 +418,13 @@ const char *DeclSpec::getSpecifierName(TSS S) {
|
|||
llvm_unreachable("Unknown typespec!");
|
||||
}
|
||||
|
||||
const char *DeclSpec::getSpecifierName(DeclSpec::TST T) {
|
||||
const char *DeclSpec::getSpecifierName(DeclSpec::TST T,
|
||||
const PrintingPolicy &Policy) {
|
||||
switch (T) {
|
||||
case DeclSpec::TST_unspecified: return "unspecified";
|
||||
case DeclSpec::TST_void: return "void";
|
||||
case DeclSpec::TST_char: return "char";
|
||||
case DeclSpec::TST_wchar: return "wchar_t";
|
||||
case DeclSpec::TST_wchar: return Policy.MSWChar ? "__wchar_t" : "wchar_t";
|
||||
case DeclSpec::TST_char16: return "char16_t";
|
||||
case DeclSpec::TST_char32: return "char32_t";
|
||||
case DeclSpec::TST_int: return "int";
|
||||
|
@ -431,7 +432,7 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T) {
|
|||
case DeclSpec::TST_half: return "half";
|
||||
case DeclSpec::TST_float: return "float";
|
||||
case DeclSpec::TST_double: return "double";
|
||||
case DeclSpec::TST_bool: return "_Bool";
|
||||
case DeclSpec::TST_bool: return Policy.Bool ? "bool" : "_Bool";
|
||||
case DeclSpec::TST_decimal32: return "_Decimal32";
|
||||
case DeclSpec::TST_decimal64: return "_Decimal64";
|
||||
case DeclSpec::TST_decimal128: return "_Decimal128";
|
||||
|
@ -467,7 +468,8 @@ const char *DeclSpec::getSpecifierName(TQ T) {
|
|||
|
||||
bool DeclSpec::SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc,
|
||||
const char *&PrevSpec,
|
||||
unsigned &DiagID) {
|
||||
unsigned &DiagID,
|
||||
const PrintingPolicy &Policy) {
|
||||
// OpenCL v1.1 s6.8g: "The extern, static, auto and register storage-class
|
||||
// specifiers are not supported.
|
||||
// It seems sensible to prohibit private_extern too
|
||||
|
@ -502,10 +504,10 @@ bool DeclSpec::SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc,
|
|||
bool isInvalid = true;
|
||||
if (TypeSpecType == TST_unspecified && S.getLangOpts().CPlusPlus) {
|
||||
if (SC == SCS_auto)
|
||||
return SetTypeSpecType(TST_auto, Loc, PrevSpec, DiagID);
|
||||
return SetTypeSpecType(TST_auto, Loc, PrevSpec, DiagID, Policy);
|
||||
if (StorageClassSpec == SCS_auto) {
|
||||
isInvalid = SetTypeSpecType(TST_auto, StorageClassSpecLoc,
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Policy);
|
||||
assert(!isInvalid && "auto SCS -> TST recovery failed");
|
||||
}
|
||||
}
|
||||
|
@ -541,7 +543,8 @@ bool DeclSpec::SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc,
|
|||
/// specified).
|
||||
bool DeclSpec::SetTypeSpecWidth(TSW W, SourceLocation Loc,
|
||||
const char *&PrevSpec,
|
||||
unsigned &DiagID) {
|
||||
unsigned &DiagID,
|
||||
const PrintingPolicy &Policy) {
|
||||
// Overwrite TSWLoc only if TypeSpecWidth was unspecified, so that
|
||||
// for 'long long' we will keep the source location of the first 'long'.
|
||||
if (TypeSpecWidth == TSW_unspecified)
|
||||
|
@ -552,7 +555,7 @@ bool DeclSpec::SetTypeSpecWidth(TSW W, SourceLocation Loc,
|
|||
TypeSpecWidth = W;
|
||||
if (TypeAltiVecVector && !TypeAltiVecBool &&
|
||||
((TypeSpecWidth == TSW_long) || (TypeSpecWidth == TSW_longlong))) {
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
|
||||
DiagID = diag::warn_vector_long_decl_spec_combination;
|
||||
return true;
|
||||
}
|
||||
|
@ -582,19 +585,21 @@ bool DeclSpec::SetTypeSpecSign(TSS S, SourceLocation Loc,
|
|||
bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
|
||||
const char *&PrevSpec,
|
||||
unsigned &DiagID,
|
||||
ParsedType Rep) {
|
||||
return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep);
|
||||
ParsedType Rep,
|
||||
const PrintingPolicy &Policy) {
|
||||
return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Policy);
|
||||
}
|
||||
|
||||
bool DeclSpec::SetTypeSpecType(TST T, SourceLocation TagKwLoc,
|
||||
SourceLocation TagNameLoc,
|
||||
const char *&PrevSpec,
|
||||
unsigned &DiagID,
|
||||
ParsedType Rep) {
|
||||
ParsedType Rep,
|
||||
const PrintingPolicy &Policy) {
|
||||
assert(isTypeRep(T) && "T does not store a type");
|
||||
assert(Rep && "no type provided!");
|
||||
if (TypeSpecType != TST_unspecified) {
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
|
||||
DiagID = diag::err_invalid_decl_spec_combination;
|
||||
return true;
|
||||
}
|
||||
|
@ -609,11 +614,12 @@ bool DeclSpec::SetTypeSpecType(TST T, SourceLocation TagKwLoc,
|
|||
bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
|
||||
const char *&PrevSpec,
|
||||
unsigned &DiagID,
|
||||
Expr *Rep) {
|
||||
Expr *Rep,
|
||||
const PrintingPolicy &Policy) {
|
||||
assert(isExprRep(T) && "T does not store an expr");
|
||||
assert(Rep && "no expression provided!");
|
||||
if (TypeSpecType != TST_unspecified) {
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
|
||||
DiagID = diag::err_invalid_decl_spec_combination;
|
||||
return true;
|
||||
}
|
||||
|
@ -628,20 +634,22 @@ bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
|
|||
bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
|
||||
const char *&PrevSpec,
|
||||
unsigned &DiagID,
|
||||
Decl *Rep, bool Owned) {
|
||||
return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Owned);
|
||||
Decl *Rep, bool Owned,
|
||||
const PrintingPolicy &Policy) {
|
||||
return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Owned, Policy);
|
||||
}
|
||||
|
||||
bool DeclSpec::SetTypeSpecType(TST T, SourceLocation TagKwLoc,
|
||||
SourceLocation TagNameLoc,
|
||||
const char *&PrevSpec,
|
||||
unsigned &DiagID,
|
||||
Decl *Rep, bool Owned) {
|
||||
Decl *Rep, bool Owned,
|
||||
const PrintingPolicy &Policy) {
|
||||
assert(isDeclRep(T) && "T does not store a decl");
|
||||
// Unlike the other cases, we don't assert that we actually get a decl.
|
||||
|
||||
if (TypeSpecType != TST_unspecified) {
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
|
||||
DiagID = diag::err_invalid_decl_spec_combination;
|
||||
return true;
|
||||
}
|
||||
|
@ -655,11 +663,12 @@ bool DeclSpec::SetTypeSpecType(TST T, SourceLocation TagKwLoc,
|
|||
|
||||
bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
|
||||
const char *&PrevSpec,
|
||||
unsigned &DiagID) {
|
||||
unsigned &DiagID,
|
||||
const PrintingPolicy &Policy) {
|
||||
assert(!isDeclRep(T) && !isTypeRep(T) && !isExprRep(T) &&
|
||||
"rep required for these type-spec kinds!");
|
||||
if (TypeSpecType != TST_unspecified) {
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
|
||||
DiagID = diag::err_invalid_decl_spec_combination;
|
||||
return true;
|
||||
}
|
||||
|
@ -672,7 +681,7 @@ bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
|
|||
TypeSpecType = T;
|
||||
TypeSpecOwned = false;
|
||||
if (TypeAltiVecVector && !TypeAltiVecBool && (TypeSpecType == TST_double)) {
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
|
||||
DiagID = diag::err_invalid_vector_decl_spec;
|
||||
return true;
|
||||
}
|
||||
|
@ -680,9 +689,10 @@ bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
|
|||
}
|
||||
|
||||
bool DeclSpec::SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
|
||||
const char *&PrevSpec, unsigned &DiagID) {
|
||||
const char *&PrevSpec, unsigned &DiagID,
|
||||
const PrintingPolicy &Policy) {
|
||||
if (TypeSpecType != TST_unspecified) {
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
|
||||
DiagID = diag::err_invalid_vector_decl_spec_combination;
|
||||
return true;
|
||||
}
|
||||
|
@ -692,10 +702,11 @@ bool DeclSpec::SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
|
|||
}
|
||||
|
||||
bool DeclSpec::SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
|
||||
const char *&PrevSpec, unsigned &DiagID) {
|
||||
const char *&PrevSpec, unsigned &DiagID,
|
||||
const PrintingPolicy &Policy) {
|
||||
if (!TypeAltiVecVector || TypeAltiVecPixel ||
|
||||
(TypeSpecType != TST_unspecified)) {
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
|
||||
DiagID = diag::err_invalid_pixel_decl_spec_combination;
|
||||
return true;
|
||||
}
|
||||
|
@ -706,10 +717,11 @@ bool DeclSpec::SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
|
|||
}
|
||||
|
||||
bool DeclSpec::SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc,
|
||||
const char *&PrevSpec, unsigned &DiagID) {
|
||||
const char *&PrevSpec, unsigned &DiagID,
|
||||
const PrintingPolicy &Policy) {
|
||||
if (!TypeAltiVecVector || TypeAltiVecBool ||
|
||||
(TypeSpecType != TST_unspecified)) {
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
|
||||
PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
|
||||
DiagID = diag::err_invalid_vector_bool_decl_spec;
|
||||
return true;
|
||||
}
|
||||
|
@ -901,7 +913,7 @@ void DeclSpec::SaveWrittenBuiltinSpecs() {
|
|||
/// "_Imaginary" (lacking an FP type). This returns a diagnostic to issue or
|
||||
/// diag::NUM_DIAGNOSTICS if there is no error. After calling this method,
|
||||
/// DeclSpec is guaranteed self-consistent, even if an error occurred.
|
||||
void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP) {
|
||||
void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP, const PrintingPolicy &Policy) {
|
||||
// Before possibly changing their values, save specs as written.
|
||||
SaveWrittenBuiltinSpecs();
|
||||
|
||||
|
@ -954,7 +966,7 @@ void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP) {
|
|||
(TypeSpecType != TST_int)) || TypeAltiVecPixel) {
|
||||
Diag(D, TSTLoc, diag::err_invalid_vector_bool_decl_spec)
|
||||
<< (TypeAltiVecPixel ? "__pixel" :
|
||||
getSpecifierName((TST)TypeSpecType));
|
||||
getSpecifierName((TST)TypeSpecType, Policy));
|
||||
}
|
||||
|
||||
// Only 'short' is valid with vector bool. (PIM 2.1)
|
||||
|
@ -984,7 +996,7 @@ void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP) {
|
|||
else if (TypeSpecType != TST_int && TypeSpecType != TST_int128 &&
|
||||
TypeSpecType != TST_char && TypeSpecType != TST_wchar) {
|
||||
Diag(D, TSSLoc, diag::err_invalid_sign_spec)
|
||||
<< getSpecifierName((TST)TypeSpecType);
|
||||
<< getSpecifierName((TST)TypeSpecType, Policy);
|
||||
// signed double -> double.
|
||||
TypeSpecSign = TSS_unspecified;
|
||||
}
|
||||
|
@ -1001,7 +1013,7 @@ void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP) {
|
|||
Diag(D, TSWLoc,
|
||||
TypeSpecWidth == TSW_short ? diag::err_invalid_short_spec
|
||||
: diag::err_invalid_longlong_spec)
|
||||
<< getSpecifierName((TST)TypeSpecType);
|
||||
<< getSpecifierName((TST)TypeSpecType, Policy);
|
||||
TypeSpecType = TST_int;
|
||||
TypeSpecOwned = false;
|
||||
}
|
||||
|
@ -1011,7 +1023,7 @@ void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP) {
|
|||
TypeSpecType = TST_int; // long -> long int.
|
||||
else if (TypeSpecType != TST_int && TypeSpecType != TST_double) {
|
||||
Diag(D, TSWLoc, diag::err_invalid_long_spec)
|
||||
<< getSpecifierName((TST)TypeSpecType);
|
||||
<< getSpecifierName((TST)TypeSpecType, Policy);
|
||||
TypeSpecType = TST_int;
|
||||
TypeSpecOwned = false;
|
||||
}
|
||||
|
@ -1033,7 +1045,7 @@ void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP) {
|
|||
Diag(D, TSTLoc, diag::ext_integer_complex);
|
||||
} else if (TypeSpecType != TST_float && TypeSpecType != TST_double) {
|
||||
Diag(D, TSCLoc, diag::err_invalid_complex_spec)
|
||||
<< getSpecifierName((TST)TypeSpecType);
|
||||
<< getSpecifierName((TST)TypeSpecType, Policy);
|
||||
TypeSpecComplex = TSC_unspecified;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3282,7 +3282,7 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
|
|||
DS.getStorageClassSpec() != DeclSpec::SCS_typedef) {
|
||||
if (getLangOpts().CPlusPlus ||
|
||||
Record->getDeclContext()->isRecord())
|
||||
return BuildAnonymousStructOrUnion(S, DS, AS, Record);
|
||||
return BuildAnonymousStructOrUnion(S, DS, AS, Record, Context.getPrintingPolicy());
|
||||
|
||||
DeclaresAnything = false;
|
||||
}
|
||||
|
@ -3584,8 +3584,9 @@ static void checkDuplicateDefaultInit(Sema &S, CXXRecordDecl *Parent,
|
|||
/// (C++ [class.union]) and a C11 feature; anonymous structures
|
||||
/// are a C11 feature and GNU C++ extension.
|
||||
Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
|
||||
AccessSpecifier AS,
|
||||
RecordDecl *Record) {
|
||||
AccessSpecifier AS,
|
||||
RecordDecl *Record,
|
||||
const PrintingPolicy &Policy) {
|
||||
DeclContext *Owner = Record->getDeclContext();
|
||||
|
||||
// Diagnose whether this anonymous struct/union is an extension.
|
||||
|
@ -3615,7 +3616,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
|
|||
|
||||
// Recover by adding 'static'.
|
||||
DS.SetStorageClassSpec(*this, DeclSpec::SCS_static, SourceLocation(),
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Policy);
|
||||
}
|
||||
// C++ [class.union]p6:
|
||||
// A storage class is not allowed in a declaration of an
|
||||
|
@ -3629,7 +3630,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
|
|||
// Recover by removing the storage specifier.
|
||||
DS.SetStorageClassSpec(*this, DeclSpec::SCS_unspecified,
|
||||
SourceLocation(),
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Context.getPrintingPolicy());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9405,7 +9406,7 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
|
|||
const char* PrevSpec; // unused
|
||||
unsigned DiagID; // unused
|
||||
DS.SetTypeSpecType(DeclSpec::TST_int, FTI.ArgInfo[i].IdentLoc,
|
||||
PrevSpec, DiagID);
|
||||
PrevSpec, DiagID, Context.getPrintingPolicy());
|
||||
// Use the identifier location for the type source range.
|
||||
DS.SetRangeStart(FTI.ArgInfo[i].IdentLoc);
|
||||
DS.SetRangeEnd(FTI.ArgInfo[i].IdentLoc);
|
||||
|
@ -10018,7 +10019,8 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
|
|||
AttributeFactory attrFactory;
|
||||
DeclSpec DS(attrFactory);
|
||||
unsigned DiagID;
|
||||
bool Error = DS.SetTypeSpecType(DeclSpec::TST_int, Loc, Dummy, DiagID);
|
||||
bool Error = DS.SetTypeSpecType(DeclSpec::TST_int, Loc, Dummy, DiagID,
|
||||
Context.getPrintingPolicy());
|
||||
(void)Error; // Silence warning.
|
||||
assert(!Error && "Error setting up implicit decl!");
|
||||
SourceLocation NoLoc;
|
||||
|
|
|
@ -1976,7 +1976,8 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
|
|||
const char *PrevSpec;
|
||||
unsigned DiagID;
|
||||
if (D.getMutableDeclSpec().SetStorageClassSpec(
|
||||
*this, DeclSpec::SCS_static, ConstexprLoc, PrevSpec, DiagID)) {
|
||||
*this, DeclSpec::SCS_static, ConstexprLoc, PrevSpec, DiagID,
|
||||
Context.getPrintingPolicy())) {
|
||||
assert(DS.getStorageClassSpec() == DeclSpec::SCS_mutable &&
|
||||
"This is the only DeclSpec that should fail to be applied");
|
||||
B << 1;
|
||||
|
|
|
@ -727,13 +727,15 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
|
|||
Result = Context.WCharTy;
|
||||
else if (DS.getTypeSpecSign() == DeclSpec::TSS_signed) {
|
||||
S.Diag(DS.getTypeSpecSignLoc(), diag::ext_invalid_sign_spec)
|
||||
<< DS.getSpecifierName(DS.getTypeSpecType());
|
||||
<< DS.getSpecifierName(DS.getTypeSpecType(),
|
||||
Context.getPrintingPolicy());
|
||||
Result = Context.getSignedWCharType();
|
||||
} else {
|
||||
assert(DS.getTypeSpecSign() == DeclSpec::TSS_unsigned &&
|
||||
"Unknown TSS value");
|
||||
S.Diag(DS.getTypeSpecSignLoc(), diag::ext_invalid_sign_spec)
|
||||
<< DS.getSpecifierName(DS.getTypeSpecType());
|
||||
<< DS.getSpecifierName(DS.getTypeSpecType(),
|
||||
Context.getPrintingPolicy());
|
||||
Result = Context.getUnsignedWCharType();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
#define bool _Bool
|
||||
int test1(int argc, char** argv)
|
||||
{
|
||||
bool signed; // expected-error {{'bool' cannot be signed or unsigned}} expected-warning {{declaration does not declare anything}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#undef bool
|
||||
|
||||
typedef int bool;
|
||||
|
||||
int test2(int argc, char** argv)
|
||||
{
|
||||
bool signed; // expected-error {{'type-name' cannot be signed or unsigned}} expected-warning {{declaration does not declare anything}}
|
||||
_Bool signed; // expected-error {{'_Bool' cannot be signed or unsigned}} expected-warning {{declaration does not declare anything}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
int test(int, char**)
|
||||
{
|
||||
bool signed; // expected-error {{'bool' cannot be signed or unsigned}} expected-warning {{declaration does not declare anything}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue