]> granicus.if.org Git - clang/commitdiff
Change __extension__ to disable only diagnostics controlled by -pedantic.
authorBob Wilson <bob.wilson@apple.com>
Wed, 12 Oct 2011 19:55:31 +0000 (19:55 +0000)
committerBob Wilson <bob.wilson@apple.com>
Wed, 12 Oct 2011 19:55:31 +0000 (19:55 +0000)
This changes clang to match GCC's behavior for __extension__, which temporarily
disables the -pedantic flag.  Warnings that are enabled without -pedantic
are not affected.  Besides the general goodness of matching GCC's precedent,
my motivation for this is that macros in the arm_neon.h header need to use
__extension__ to avoid pedantic complaints about their use of statement
expressions, yet we still want to warn about incompatible pointer arguments
for those macros.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141804 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/DiagnosticIDs.cpp
test/Sema/implicit-int.c

index 9d460a5c9a8871ca7c5c9be0a59e802d89614388..9481287c08cf3a4eccf79dece411b23ef077b94e 100644 (file)
@@ -550,9 +550,12 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass,
       !MappingInfo.isUser())
     Result = DiagnosticIDs::Warning;
 
-  // Ignore any kind of extension diagnostics inside __extension__ blocks.
-  bool IsExtensionDiag = isBuiltinExtensionDiag(DiagID);
-  if (Diag.AllExtensionsSilenced && IsExtensionDiag)
+  // Ignore -pedantic diagnostics inside __extension__ blocks.
+  // (The diagnostics controlled by -pedantic are the extension diagnostics
+  // that are not enabled by default.)
+  bool EnabledByDefault;
+  bool IsExtensionDiag = isBuiltinExtensionDiag(DiagID, EnabledByDefault);
+  if (Diag.AllExtensionsSilenced && IsExtensionDiag && !EnabledByDefault)
     return DiagnosticIDs::Ignored;
 
   // For extension diagnostics that haven't been explicitly mapped, check if we
index 1bb9a838530660bf1ea9638be2dab295ba245786..3063db66ed854d1e27e187da242065c1f018e8c1 100644 (file)
@@ -24,9 +24,5 @@ h19_insline(n)  // expected-warning {{parameter 'n' was not declared, defaulting
 }
 
 struct foo {
- __extension__ __attribute__((packed)) x : 4;
+ __extension__ __attribute__((packed)) x : 4; // expected-warning {{type specifier missing, defaults to 'int'}}
 };
-
-
-
-