def StrncatSize : DiagGroup<"strncat-size">;
def TautologicalCompare : DiagGroup<"tautological-compare">;
def HeaderHygiene : DiagGroup<"header-hygiene">;
+def DuplicateDeclSpecifiers : DiagGroup<"duplicate-decl-specifiers">;
// Preprocessor warnings.
def : DiagGroup<"builtin-macro-redefined">;
"extra ';' after member function definition">,
InGroup<ExtraSemi>, DefaultIgnore;
-def ext_duplicate_declspec : Extension<"duplicate '%0' declaration specifier">;
+def ext_duplicate_declspec : ExtWarn<"duplicate '%0' declaration specifier">,
+ InGroup<DuplicateDeclSpecifiers>;
+def warn_duplicate_declspec : Warning<"duplicate '%0' declaration specifier">,
+ InGroup<DuplicateDeclSpecifiers>;
def ext_plain_complex : ExtWarn<
"plain '_Complex' requires a type specifier; assuming '_Complex double'">;
def ext_integer_complex : Extension<
template <class T> static bool BadSpecifier(T TNew, T TPrev,
const char *&PrevSpec,
- unsigned &DiagID) {
+ unsigned &DiagID,
+ bool IsExtension = true) {
PrevSpec = DeclSpec::getSpecifierName(TPrev);
- DiagID = (TNew == TPrev ? diag::ext_duplicate_declspec
- : diag::err_invalid_decl_spec_combination);
+ if (TNew != TPrev)
+ DiagID = diag::err_invalid_decl_spec_combination;
+ else
+ DiagID = IsExtension ? diag::ext_duplicate_declspec :
+ diag::warn_duplicate_declspec;
return true;
}
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);
+ // cv-qualifier appears as a type-specifier. However, since this is likely
+ // not what the user intended, we will always warn. We do not need to set the
+ // qualifier's location since we already have it.
+ if (TypeQualifiers & T) {
+ bool IsExtension = false;
+ if (Lang.C99 || (Lang.CPlusPlus0x && !IsTypeSpec))
+ IsExtension = true;
+ return BadSpecifier(T, T, PrevSpec, DiagID, IsExtension);
+ }
TypeQualifiers |= T;
switch (T) {
The list of warnings in -Wpedantic should NEVER grow.
-CHECK: Number in -Wpedantic (not covered by other -W flags): 39
+CHECK: Number in -Wpedantic (not covered by other -W flags): 38
// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic %s
+const char const *x10; // expected-warning {{duplicate 'const' declaration specifier}}
+
int x(*g); // expected-error {{use of undeclared identifier 'g'}}
struct Type {
void i() = delete;;; // expected-warning {{extra ';' after member function definition}}
};
-int *const const p = 0; // ok
+// This is technically okay, but not likely what the user expects, so we will
+// pedantically warn on it
+int *const const p = 0; // expected-warning {{duplicate 'const' declaration specifier}}
const const int *q = 0; // expected-warning {{duplicate 'const' declaration specifier}}