forked from OSchip/llvm-project
Pedantic -pedantic correction. Duplicate cv-qualifiers are permitted in C++11
unless they appear in a decl-specifier-seq. llvm-svn: 160688
This commit is contained in:
parent
5b8c1680de
commit
7ac3c6af87
|
@ -598,7 +598,8 @@ public:
|
|||
}
|
||||
|
||||
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
|
||||
unsigned &DiagID, const LangOptions &Lang);
|
||||
unsigned &DiagID, const LangOptions &Lang,
|
||||
bool IsTypeSpec);
|
||||
|
||||
bool SetFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
|
||||
unsigned &DiagID);
|
||||
|
|
|
@ -2666,15 +2666,15 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
|
|||
// cv-qualifier:
|
||||
case tok::kw_const:
|
||||
isInvalid = DS.SetTypeQual(DeclSpec::TQ_const, Loc, PrevSpec, DiagID,
|
||||
getLangOpts());
|
||||
getLangOpts(), /*IsTypeSpec*/true);
|
||||
break;
|
||||
case tok::kw_volatile:
|
||||
isInvalid = DS.SetTypeQual(DeclSpec::TQ_volatile, Loc, PrevSpec, DiagID,
|
||||
getLangOpts());
|
||||
getLangOpts(), /*IsTypeSpec*/true);
|
||||
break;
|
||||
case tok::kw_restrict:
|
||||
isInvalid = DS.SetTypeQual(DeclSpec::TQ_restrict, Loc, PrevSpec, DiagID,
|
||||
getLangOpts());
|
||||
getLangOpts(), /*IsTypeSpec*/true);
|
||||
break;
|
||||
|
||||
// C++ typename-specifier:
|
||||
|
@ -3869,15 +3869,15 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS,
|
|||
|
||||
case tok::kw_const:
|
||||
isInvalid = DS.SetTypeQual(DeclSpec::TQ_const , Loc, PrevSpec, DiagID,
|
||||
getLangOpts());
|
||||
getLangOpts(), /*IsTypeSpec*/false);
|
||||
break;
|
||||
case tok::kw_volatile:
|
||||
isInvalid = DS.SetTypeQual(DeclSpec::TQ_volatile, Loc, PrevSpec, DiagID,
|
||||
getLangOpts());
|
||||
getLangOpts(), /*IsTypeSpec*/false);
|
||||
break;
|
||||
case tok::kw_restrict:
|
||||
isInvalid = DS.SetTypeQual(DeclSpec::TQ_restrict, Loc, PrevSpec, DiagID,
|
||||
getLangOpts());
|
||||
getLangOpts(), /*IsTypeSpec*/false);
|
||||
break;
|
||||
|
||||
// OpenCL qualifiers:
|
||||
|
|
|
@ -668,9 +668,11 @@ bool DeclSpec::SetTypeSpecError() {
|
|||
}
|
||||
|
||||
bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
|
||||
unsigned &DiagID, const LangOptions &Lang) {
|
||||
// Duplicates turn into warnings pre-C99.
|
||||
if ((TypeQualifiers & T) && !Lang.C99)
|
||||
unsigned &DiagID, const LangOptions &Lang,
|
||||
bool IsTypeSpec) {
|
||||
// Duplicates are permitted in C99, and are permitted in C++11 unless the
|
||||
// cv-qualifier appears as a type-specifier.
|
||||
if ((TypeQualifiers & T) && !Lang.C99 && (!Lang.CPlusPlus0x || IsTypeSpec))
|
||||
return BadSpecifier(T, T, PrevSpec, DiagID);
|
||||
TypeQualifiers |= T;
|
||||
|
||||
|
|
|
@ -25,3 +25,6 @@ class ExtraSemiAfterMemFn {
|
|||
void h() = delete;; // ok
|
||||
void i() = delete;;; // expected-warning {{extra ';' after member function definition}}
|
||||
};
|
||||
|
||||
int *const const p = 0; // ok
|
||||
const const int *q = 0; // expected-warning {{duplicate 'const' declaration specifier}}
|
||||
|
|
Loading…
Reference in New Issue