[cfe-commits] r160688 - in /cfe/trunk: include/clang/Sema/DeclSpec.h lib/Parse/ParseDecl.cpp lib/Sema/DeclSpec.cpp test/Parser/cxx0x-decl.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Tue Jul 24 13:24:59 PDT 2012
Author: rsmith
Date: Tue Jul 24 15:24:58 2012
New Revision: 160688
URL: http://llvm.org/viewvc/llvm-project?rev=160688&view=rev
Log:
Pedantic -pedantic correction. Duplicate cv-qualifiers are permitted in C++11
unless they appear in a decl-specifier-seq.
Modified:
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/test/Parser/cxx0x-decl.cpp
Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=160688&r1=160687&r2=160688&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Tue Jul 24 15:24:58 2012
@@ -598,7 +598,8 @@
}
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);
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=160688&r1=160687&r2=160688&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Jul 24 15:24:58 2012
@@ -2666,15 +2666,15 @@
// 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 @@
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:
Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=160688&r1=160687&r2=160688&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Tue Jul 24 15:24:58 2012
@@ -668,9 +668,11 @@
}
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;
Modified: cfe/trunk/test/Parser/cxx0x-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-decl.cpp?rev=160688&r1=160687&r2=160688&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-decl.cpp Tue Jul 24 15:24:58 2012
@@ -25,3 +25,6 @@
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}}
More information about the cfe-commits
mailing list