aaron.ballman updated this revision to Diff 421786.
aaron.ballman added a comment.

Rebased


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122983/new/

https://reviews.llvm.org/D122983

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/ARCMT/objcmt-arc-cf-annotations.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
  clang/test/Analysis/OSAtomic_mac.c
  clang/test/Analysis/ObjCProperties.m
  clang/test/Analysis/PR49642.c
  clang/test/Analysis/diagnostics/no-store-func-path-notes.c
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/novoidtypecrash.c
  clang/test/Analysis/plist-macros-with-expansion.c
  clang/test/CodeGen/2002-07-14-MiscTests3.c
  clang/test/CodeGen/2002-07-31-SubregFailure.c
  clang/test/CodeGen/2003-08-18-SigSetJmp.c
  clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c
  clang/test/CodeGen/2005-01-02-ConstantInits.c
  clang/test/CodeGen/2005-01-02-VAArgError-ICE.c
  clang/test/CodeGen/2006-01-13-StackSave.c
  clang/test/CodeGen/2006-03-03-MissingInitializer.c
  clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c
  clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c
  clang/test/CodeGen/2008-08-19-cast-of-typedef.c
  clang/test/CodeGen/2008-10-13-FrontendCrash.c
  clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c
  clang/test/CodeGen/X86/bmi2-builtins.c
  clang/test/CodeGen/aarch64-mops.c
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/attribute_constructor.c
  clang/test/CodeGen/builtins-arm-microsoft.c
  clang/test/CodeGen/builtins-arm-msvc-compat-only.c
  clang/test/CodeGen/cast-emit.c
  clang/test/CodeGen/debug-info-block-vars.c
  clang/test/CodeGen/debug-info-crash.c
  clang/test/CodeGen/decl.c
  clang/test/CodeGen/init-with-member-expr.c
  clang/test/CodeGen/misaligned-param.c
  clang/test/CodeGen/neon-crypto.c
  clang/test/CodeGen/struct-comma.c
  clang/test/CodeGen/variable-array.c
  clang/test/Frontend/warning-mapping-2.c
  clang/test/Headers/arm-cmse-header-ns.c
  clang/test/Import/objc-arc/test-cleanup-object.m
  clang/test/Modules/config_macros.m
  clang/test/Modules/modulemap-locations.m
  clang/test/OpenMP/declare_mapper_messages.c
  clang/test/PCH/chain-macro-override.c
  clang/test/Rewriter/rewrite-foreach-2.m
  clang/test/Rewriter/rewrite-try-catch.m
  clang/test/Sema/__try.c
  clang/test/Sema/aarch64-tme-errors.c
  clang/test/Sema/arm-no-fp16.c
  clang/test/Sema/bitfield.c
  clang/test/Sema/builtin-setjmp.c
  clang/test/Sema/builtins.c
  clang/test/Sema/cxx-as-c.c
  clang/test/Sema/implicit-builtin-decl.c
  clang/test/Sema/implicit-decl.c
  clang/test/Sema/implicit-ms-builtin-decl.c
  clang/test/Sema/typo-correction.c
  clang/test/Sema/vla.c
  clang/test/Sema/warn-strict-prototypes.c
  clang/test/VFS/module_missing_vfs.m
  compiler-rt/test/safestack/pthread-cleanup.c

Index: compiler-rt/test/safestack/pthread-cleanup.c
===================================================================
--- compiler-rt/test/safestack/pthread-cleanup.c
+++ compiler-rt/test/safestack/pthread-cleanup.c
@@ -17,6 +17,8 @@
   return buffer;
 }
 
+extern unsigned sleep(unsigned seconds);
+
 int main(int argc, char **argv)
 {
   int arg = atoi(argv[1]);
Index: clang/test/VFS/module_missing_vfs.m
===================================================================
--- clang/test/VFS/module_missing_vfs.m
+++ clang/test/VFS/module_missing_vfs.m
@@ -1,12 +1,12 @@
 // RUN: rm -rf %t && mkdir -p %t
 // RUN: echo "void funcA(void);" >> %t/a.h
 
-// RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml 2>&1 | FileCheck %s -check-prefix=ERROR
+// RUN: not %clang_cc1 -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml 2>&1 | FileCheck %s -check-prefix=ERROR
 // ERROR: virtual filesystem overlay file '{{.*}}' not found
 // RUN: find %t/mcp -name "A-*.pcm" | count 1
 
 // RUN: sed -e "s@INPUT_DIR@%{/S:regex_replacement}/Inputs@g" -e "s@OUT_DIR@%{/t:regex_replacement}@g" %S/Inputs/MissingVFS/vfsoverlay.yaml > %t/vfs.yaml
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml
+// RUN: %clang_cc1 -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml
 // RUN: find %t/mcp -name "A-*.pcm" | count 1
 
 @import A;
Index: clang/test/Sema/warn-strict-prototypes.c
===================================================================
--- clang/test/Sema/warn-strict-prototypes.c
+++ clang/test/Sema/warn-strict-prototypes.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -Wno-implicit-function-declaration -verify %s
-// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -Wno-implicit-function-declaration -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 // function definition with 0 params, no prototype, no preceding declaration.
 void foo0() {} // expected-warning {{a function declaration without a prototype is deprecated in all versions of C}}
Index: clang/test/Sema/vla.c
===================================================================
--- clang/test/Sema/vla.c
+++ clang/test/Sema/vla.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
+// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic -std=c99
 
 int test1(void) {
   typedef int x[test1()];  // vla
Index: clang/test/Sema/typo-correction.c
===================================================================
--- clang/test/Sema/typo-correction.c
+++ clang/test/Sema/typo-correction.c
@@ -37,7 +37,7 @@
 
 typedef long long __m128i __attribute__((__vector_size__(16)));
 int PR23101(__m128i __x) {
-  return foo((__v2di)__x);  // expected-warning {{implicit declaration of function 'foo'}} \
+  return foo((__v2di)__x);  // expected-error {{implicit declaration of function 'foo'}} \
                             // expected-error {{use of undeclared identifier '__v2di'}}
 }
 
Index: clang/test/Sema/implicit-ms-builtin-decl.c
===================================================================
--- clang/test/Sema/implicit-ms-builtin-decl.c
+++ clang/test/Sema/implicit-ms-builtin-decl.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s -fms-extensions
-// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -verify %s -fms-extensions
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -verify %s -fms-extensions -std=c99
 
 void f(void) {
   (void)_byteswap_ushort(42); // expected-warning{{implicitly declaring library function '_byteswap_ushort'}} \
Index: clang/test/Sema/implicit-decl.c
===================================================================
--- clang/test/Sema/implicit-decl.c
+++ clang/test/Sema/implicit-decl.c
@@ -1,24 +1,36 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -Werror=implicit-function-declaration
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Werror=implicit-function-declaration -std=c99
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+// RUN: %clang_cc1 %s -verify=c2x -fsyntax-only -std=c2x
 
 /// -Werror-implicit-function-declaration is a deprecated alias used by many projects.
 // RUN: %clang_cc1 %s -verify -fsyntax-only -Werror-implicit-function-declaration
 
+// c2x-note@*:* {{'__builtin_va_list' declared here}}
+
 typedef int int32_t;
 typedef unsigned char Boolean;
 
-extern int printf(__const char *__restrict __format, ...); // expected-note{{'printf' declared here}}
+extern int printf(__const char *__restrict __format, ...); // expected-note{{'printf' declared here}} \
+                                                              c2x-note {{'printf' declared here}}
 
 void func(void) {
    int32_t *vector[16];
    const char compDesc[16 + 1];
    int32_t compCount = 0;
-   if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-error {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}} expected-note {{previous implicit declaration}}
+   if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-error {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}} \
+                                                                            expected-note {{previous implicit declaration}} \
+                                                                            c2x-error {{use of undeclared identifier '_CFCalendarDecomposeAbsoluteTimeV'}}
    }
 
    printg("Hello, World!\n"); // expected-error{{implicit declaration of function 'printg' is invalid in C99}} \
-                              // expected-note{{did you mean 'printf'?}}
-
-  __builtin_is_les(1, 3); // expected-error{{use of unknown builtin '__builtin_is_les'}}
+                                 expected-note{{did you mean 'printf'?}} \
+                                 c2x-error {{use of undeclared identifier 'printg'; did you mean 'printf'?}}
+
+  __builtin_is_les(1, 3); // expected-error{{use of unknown builtin '__builtin_is_les'}} \
+                             c2x-error {{unknown type name '__builtin_is_les'; did you mean '__builtin_va_list'?}} \
+                             c2x-error {{expected identifier or '('}} \
+                             c2x-error {{expected ')'}} \
+                             c2x-note {{to match this '('}}
 }
 Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // expected-error {{conflicting types}}
  return 0;
@@ -28,7 +40,9 @@
 // Test the typo-correction callback in Sema::ImplicitlyDefineFunction
 extern int sformatf(char *str, __const char *__restrict __format, ...); // expected-note{{'sformatf' declared here}}
 void test_implicit(void) {
-  int formats = 0;
+  int formats = 0; // c2x-note {{'formats' declared here}}
   formatd("Hello, World!\n"); // expected-error{{implicit declaration of function 'formatd' is invalid in C99}} \
-                              // expected-note{{did you mean 'sformatf'?}}
+                                 expected-note{{did you mean 'sformatf'?}} \
+                                 c2x-error {{use of undeclared identifier 'formatd'; did you mean 'formats'?}} \
+                                 c2x-error {{called object type 'int' is not a function or function pointer}}
 }
Index: clang/test/Sema/implicit-builtin-decl.c
===================================================================
--- clang/test/Sema/implicit-builtin-decl.c
+++ clang/test/Sema/implicit-builtin-decl.c
@@ -24,7 +24,7 @@
 
 void f2() {
   fprintf(0, "foo"); // expected-warning{{declaration of built-in function 'fprintf' requires inclusion of the header <stdio.h>}} \
-   expected-warning {{implicit declaration of function 'fprintf' is invalid in C99}}
+   expected-error {{implicit declaration of function 'fprintf' is invalid in C99}}
 }
 
 // PR2892
Index: clang/test/Sema/cxx-as-c.c
===================================================================
--- clang/test/Sema/cxx-as-c.c
+++ clang/test/Sema/cxx-as-c.c
@@ -2,7 +2,7 @@
 
 // PR36157
 struct Foo {
-  Foo(int n) : n_(n) {} // expected-error 1+{{}} expected-warning 1+{{}}
+  Foo(int n) : n_(n) {} // expected-error 1+{{}}
 private:
   int n;
 };
Index: clang/test/Sema/builtins.c
===================================================================
--- clang/test/Sema/builtins.c
+++ clang/test/Sema/builtins.c
@@ -207,9 +207,9 @@
 }
 
 void no_ms_builtins(void) {
-  __assume(1); // expected-warning {{implicit declaration}}
-  __noop(1); // expected-warning {{implicit declaration}}
-  __debugbreak(); // expected-warning {{implicit declaration}}
+  __assume(1); // expected-error {{implicit declaration}}
+  __noop(1); // expected-error {{implicit declaration}}
+  __debugbreak(); // expected-error {{implicit declaration}}
 }
 
 void unavailable(void) {
Index: clang/test/Sema/builtin-setjmp.c
===================================================================
--- clang/test/Sema/builtin-setjmp.c
+++ clang/test/Sema/builtin-setjmp.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=c,expected -DWRONG_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=c,expected -DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=c,expected -DONLY_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=c,expected -DNO_SETJMP %s -ast-dump 2>&1 | FileCheck %s --check-prefixes=CHECK1,CHECK2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=c,expected -std=c99 -DNO_SETJMP %s -ast-dump 2>&1 | FileCheck %s --check-prefixes=CHECK1,CHECK2
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=cxx,expected -x c++ -DNO_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=cxx,expected -x c++ -DWRONG_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify=cxx,expected -x c++ -DRIGHT_JMP_BUF %s -ast-dump | FileCheck %s --check-prefixes=CHECK1,CHECK2
Index: clang/test/Sema/bitfield.c
===================================================================
--- clang/test/Sema/bitfield.c
+++ clang/test/Sema/bitfield.c
@@ -84,5 +84,5 @@
 };
 
 struct PR36157 {
-  int n : 1 ? 1 : implicitly_declare_function(); // expected-warning {{invalid in C99}}
+  int n : 1 ? 1 : implicitly_declare_function(); // expected-error {{invalid in C99}}
 };
Index: clang/test/Sema/arm-no-fp16.c
===================================================================
--- clang/test/Sema/arm-no-fp16.c
+++ clang/test/Sema/arm-no-fp16.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple thumbv7-none-eabi %s -target-feature +neon \
 // RUN:   -fallow-half-arguments-and-returns -target-feature -fp16 \
-// RUN:   -fsyntax-only -verify
+// RUN:   -fsyntax-only -verify -std=c99
 
 // REQUIRES: aarch64-registered-target || arm-registered-target
 
Index: clang/test/Sema/aarch64-tme-errors.c
===================================================================
--- clang/test/Sema/aarch64-tme-errors.c
+++ clang/test/Sema/aarch64-tme-errors.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple aarch64-eabi -verify %s
+// RUN: %clang_cc1 -triple aarch64-eabi -verify -std=c99 %s
 
 #include "arm_acle.h"
 
Index: clang/test/Sema/__try.c
===================================================================
--- clang/test/Sema/__try.c
+++ clang/test/Sema/__try.c
@@ -50,7 +50,7 @@
 }  // expected-error{{expected '__except' or '__finally' block}}
 
 void TEST(void) {
-  __except (FilterExpression()) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
+  __except (FilterExpression()) { // expected-error{{implicit declaration of function '__except' is invalid in C99}} \
     // expected-error{{too few arguments to function call, expected 1, have 0}} \
     // expected-error{{expected ';' after expression}}
   }
Index: clang/test/Rewriter/rewrite-try-catch.m
===================================================================
--- clang/test/Rewriter/rewrite-try-catch.m
+++ clang/test/Rewriter/rewrite-try-catch.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5  %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -std=c99 %s -o -
 
 @interface Foo @end
 @interface GARF @end
Index: clang/test/Rewriter/rewrite-foreach-2.m
===================================================================
--- clang/test/Rewriter/rewrite-foreach-2.m
+++ clang/test/Rewriter/rewrite-foreach-2.m
@@ -25,7 +25,7 @@
         for (el in self) 
 	  { LOOP(); 
             for (id el1 in self) 
-	       INNER_LOOP();
+	       INNERLOOP();
 
 	    END_LOOP();
 	  }
Index: clang/test/PCH/chain-macro-override.c
===================================================================
--- clang/test/PCH/chain-macro-override.c
+++ clang/test/PCH/chain-macro-override.c
@@ -1,10 +1,10 @@
 // Test this without pch.
-// RUN: %clang_cc1 -include %S/Inputs/chain-macro-override1.h -include %S/Inputs/chain-macro-override2.h -fsyntax-only -verify -detailed-preprocessing-record %s
+// RUN: %clang_cc1 -std=c99 -include %S/Inputs/chain-macro-override1.h -include %S/Inputs/chain-macro-override2.h -fsyntax-only -verify -detailed-preprocessing-record %s
 
 // Test with pch.
-// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-macro-override1.h -detailed-preprocessing-record 
-// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-macro-override2.h -include-pch %t1 -detailed-preprocessing-record 
-// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c99 -emit-pch -o %t1 %S/Inputs/chain-macro-override1.h -detailed-preprocessing-record 
+// RUN: %clang_cc1 -std=c99 -emit-pch -o %t2 %S/Inputs/chain-macro-override2.h -include-pch %t1 -detailed-preprocessing-record 
+// RUN: %clang_cc1 -std=c99 -include-pch %t2 -fsyntax-only -verify %s
 
 int foo(void) {
   f();
Index: clang/test/OpenMP/declare_mapper_messages.c
===================================================================
--- clang/test/OpenMP/declare_mapper_messages.c
+++ clang/test/OpenMP/declare_mapper_messages.c
@@ -42,9 +42,9 @@
       {}
 #pragma omp target map(mapper:vv)                                       // expected-error {{expected '(' after 'mapper'}}
       {}
-#pragma omp target map(mapper( :vv)                                     // expected-error {{expected expression}} expected-error {{expected ')'}} expected-warning {{implicit declaration of function 'mapper' is invalid in C99}} expected-note {{to match this '('}}
+#pragma omp target map(mapper( :vv)                                     // expected-error {{expected expression}} expected-error {{expected ')'}} expected-error {{implicit declaration of function 'mapper' is invalid in C99}} expected-note {{to match this '('}}
       {}
-#pragma omp target map(mapper(aa :vv)                                   // expected-error {{use of undeclared identifier 'aa'}} expected-error {{expected ')'}} expected-warning {{implicit declaration of function 'mapper' is invalid in C99}} expected-note {{to match this '('}}
+#pragma omp target map(mapper(aa :vv)                                   // expected-error {{use of undeclared identifier 'aa'}} expected-error {{expected ')'}} expected-error {{implicit declaration of function 'mapper' is invalid in C99}} expected-note {{to match this '('}}
       {}
 #pragma omp target map(mapper(ab) :vv)                                  // expected-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'struct vec' with name 'ab'}}
       {}
Index: clang/test/Modules/modulemap-locations.m
===================================================================
--- clang/test/Modules/modulemap-locations.m
+++ clang/test/Modules/modulemap-locations.m
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t 
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/ModuleMapLocations/Module_ModuleMap -I %S/Inputs/ModuleMapLocations/Both -F %S/Inputs/ModuleMapLocations -I %S/Inputs/ModuleMapLocations -F %S/Inputs -x objective-c -fsyntax-only %s -verify -Wno-private-module
+// RUN: %clang_cc1 -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/ModuleMapLocations/Module_ModuleMap -I %S/Inputs/ModuleMapLocations/Both -F %S/Inputs/ModuleMapLocations -I %S/Inputs/ModuleMapLocations -F %S/Inputs -x objective-c -fsyntax-only %s -verify -Wno-private-module
 
 // regular
 @import module_modulemap;
Index: clang/test/Modules/config_macros.m
===================================================================
--- clang/test/Modules/config_macros.m
+++ clang/test/Modules/config_macros.m
@@ -23,6 +23,6 @@
 @import config; // expected-warning{{definition of configuration macro 'WANT_BAR' has no effect on the import of 'config'; pass '-DWANT_BAR=...' on the command line to configure the module}}
 
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x objective-c -fmodules-cache-path=%t -DWANT_FOO=1 -emit-module -fmodule-name=config %S/Inputs/module.map
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -DWANT_FOO=1 %s -verify
+// RUN: %clang_cc1 -std=c99 -fmodules -fimplicit-module-maps -x objective-c -fmodules-cache-path=%t -DWANT_FOO=1 -emit-module -fmodule-name=config %S/Inputs/module.map
+// RUN: %clang_cc1 -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -DWANT_FOO=1 %s -verify
 
Index: clang/test/Import/objc-arc/test-cleanup-object.m
===================================================================
--- clang/test/Import/objc-arc/test-cleanup-object.m
+++ clang/test/Import/objc-arc/test-cleanup-object.m
@@ -5,6 +5,7 @@
 // CHECK: ExprWithCleanups
 // CHECK-NEXT: cleanup CompoundLiteralExpr
 
+extern int getObj();
 void test(int c, id a) {
   (void)getObj(c, a);
 }
Index: clang/test/Headers/arm-cmse-header-ns.c
===================================================================
--- clang/test/Headers/arm-cmse-header-ns.c
+++ clang/test/Headers/arm-cmse-header-ns.c
@@ -1,4 +1,4 @@
-// RUN:     %clang_cc1 -triple thumbv8m.base-eabi -fsyntax-only        %s 2>&1 | FileCheck --check-prefix=CHECK-c %s
+// RUN:     %clang_cc1 -triple thumbv8m.base-eabi -fsyntax-only -std=c99 %s 2>&1 | FileCheck --check-prefix=CHECK-c %s
 // RUN: not %clang_cc1 -triple thumbv8m.base-eabi -fsyntax-only -x c++ %s 2>&1 | FileCheck --check-prefix=CHECK-cpp %s
 
 #include <arm_cmse.h>
Index: clang/test/Frontend/warning-mapping-2.c
===================================================================
--- clang/test/Frontend/warning-mapping-2.c
+++ clang/test/Frontend/warning-mapping-2.c
@@ -1,5 +1,5 @@
 // Check that -w takes precedence over -pedantic-errors.
-// RUN: %clang_cc1 -verify -pedantic-errors -w %s
+// RUN: %clang_cc1 -verify -std=c89 -pedantic-errors -w %s
 
 // Expect *not* to see a diagnostic for "implicit declaration of function"
 // expected-no-diagnostics
Index: clang/test/CodeGen/variable-array.c
===================================================================
--- clang/test/CodeGen/variable-array.c
+++ clang/test/CodeGen/variable-array.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm < %s | grep puts | count 4
+// RUN: %clang_cc1 -std=c99 -emit-llvm < %s | grep puts | count 4
 
 // PR3248
 int a(int x)
Index: clang/test/CodeGen/struct-comma.c
===================================================================
--- clang/test/CodeGen/struct-comma.c
+++ clang/test/CodeGen/struct-comma.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -o -
 
 struct S {int a, b;} x;
+extern int r(void);
 void a(struct S* b) {*b = (r(), x);}
Index: clang/test/CodeGen/neon-crypto.c
===================================================================
--- clang/test/CodeGen/neon-crypto.c
+++ clang/test/CodeGen/neon-crypto.c
@@ -5,7 +5,7 @@
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
 // RUN:   -target-feature +sha2 -target-feature +aes \
 // RUN:   -emit-llvm -O1 -o - %s | FileCheck %s
-// RUN: not %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
+// RUN: not %clang_cc1 -std=c99 -triple arm64-none-linux-gnu -target-feature +neon \
 // RUN:   -S -O3 -o - %s 2>&1 | FileCheck --check-prefix=CHECK-NO-CRYPTO %s
 
 // REQUIRES: aarch64-registered-target || arm-registered-target
Index: clang/test/CodeGen/misaligned-param.c
===================================================================
--- clang/test/CodeGen/misaligned-param.c
+++ clang/test/CodeGen/misaligned-param.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple i386-apple-darwin -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -std=c89 -triple i386-apple-darwin -emit-llvm -o - | FileCheck %s
 // Misaligned parameter must be memcpy'd to correctly aligned temporary.
 
 struct s { int x; long double y; };
Index: clang/test/CodeGen/init-with-member-expr.c
===================================================================
--- clang/test/CodeGen/init-with-member-expr.c
+++ clang/test/CodeGen/init-with-member-expr.c
@@ -12,6 +12,7 @@
 typedef struct mark_header_tag {
  unsigned char mark[7];
 } mark_header_t;
+extern int foo();
 int is_rar_archive(int fd) {
         const mark_header_t rar_hdr[2] = {{0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00}, {'U', 'n', 'i', 'q', 'u', 'E', '!'}};
         foo(rar_hdr);
Index: clang/test/CodeGen/decl.c
===================================================================
--- clang/test/CodeGen/decl.c
+++ clang/test/CodeGen/decl.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -no-opaque-pointers -w -fmerge-all-constants -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -std=c89 -w -fmerge-all-constants -emit-llvm < %s | FileCheck %s
 
 // CHECK: @test1.x = internal constant [12 x i32] [i32 1
 // CHECK: @__const.test2.x = private unnamed_addr constant [13 x i32] [i32 1,
Index: clang/test/CodeGen/debug-info-crash.c
===================================================================
--- clang/test/CodeGen/debug-info-crash.c
+++ clang/test/CodeGen/debug-info-crash.c
@@ -1,5 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -debug-info-kind=limited -S %s -o -
+// RUN: %clang_cc1 -std=c89 -triple i386-apple-darwin10 -fblocks -debug-info-kind=limited -S %s -o -
 
 // rdar://7590323
 typedef struct dispatch_queue_s *dispatch_queue_t;
Index: clang/test/CodeGen/debug-info-block-vars.c
===================================================================
--- clang/test/CodeGen/debug-info-block-vars.c
+++ clang/test/CodeGen/debug-info-block-vars.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -no-opaque-pointers -x c -fblocks -debug-info-kind=standalone -emit-llvm -O0 \
+// RUN: %clang_cc1 -no-opaque-pointers -x c -std=c89 -fblocks -debug-info-kind=standalone -emit-llvm -O0 \
 // RUN:   -triple x86_64-apple-darwin -o - %s | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -x c -fblocks -debug-info-kind=standalone -emit-llvm -O1 \
+// RUN: %clang_cc1 -no-opaque-pointers -x c -std=c89 -fblocks -debug-info-kind=standalone -emit-llvm -O1 \
 // RUN:   -triple x86_64-apple-darwin -o - %s \
 // RUN:   | FileCheck --check-prefix=CHECK-OPT %s
 
Index: clang/test/CodeGen/cast-emit.c
===================================================================
--- clang/test/CodeGen/cast-emit.c
+++ clang/test/CodeGen/cast-emit.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
 
+extern int f();
 typedef union {
   int    i;
   float  f;
Index: clang/test/CodeGen/builtins-arm-msvc-compat-only.c
===================================================================
--- clang/test/CodeGen/builtins-arm-msvc-compat-only.c
+++ clang/test/CodeGen/builtins-arm-msvc-compat-only.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple thumbv7-windows -fms-extensions -emit-llvm -o - %s \
 // RUN:     | FileCheck %s -check-prefix CHECK-MSVC
-// RUN: %clang_cc1 -triple armv7-eabi -emit-llvm %s -o /dev/null 2>&1 \
+// RUN: %clang_cc1 -std=c99 -triple armv7-eabi -emit-llvm %s -o /dev/null 2>&1 \
 // RUN:     | FileCheck %s -check-prefix CHECK-EABI
 // REQUIRES: arm-registered-target
 
Index: clang/test/CodeGen/builtins-arm-microsoft.c
===================================================================
--- clang/test/CodeGen/builtins-arm-microsoft.c
+++ clang/test/CodeGen/builtins-arm-microsoft.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -emit-llvm -o - %s \
 // RUN:     | FileCheck %s -check-prefix CHECK-MSVC
-// RUN: %clang_cc1 -triple armv7-eabi -emit-llvm %s -o - \
+// RUN: %clang_cc1 -std=c99 -triple armv7-eabi -emit-llvm %s -o - \
 // RUN:     | FileCheck %s -check-prefix CHECK-EABI
 // REQUIRES: arm-registered-target
 
Index: clang/test/CodeGen/attribute_constructor.c
===================================================================
--- clang/test/CodeGen/attribute_constructor.c
+++ clang/test/CodeGen/attribute_constructor.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - | grep llvm.global_ctors
 
+extern int bar();
 void foo(void) __attribute__((constructor));
 void foo(void) {
   bar();
Index: clang/test/CodeGen/arm_acle.c
===================================================================
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -1,6 +1,6 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -no-opaque-pointers -ffreestanding -triple armv8a-none-eabi -target-feature +crc -target-feature +dsp -O0 -disable-O0-optnone -fexperimental-new-pass-manager -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s -check-prefixes=ARM,AArch32
-// RUN: %clang_cc1 -no-opaque-pointers -ffreestanding -triple aarch64-none-eabi -target-feature +neon -target-feature +crc -target-feature +crypto -O0 -disable-O0-optnone -fexperimental-new-pass-manager -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s -check-prefixes=ARM,AArch64
+// RUN: %clang_cc1 -no-opaque-pointers -ffreestanding -Wno-error=implicit-function-declaration -triple aarch64-none-eabi -target-feature +neon -target-feature +crc -target-feature +crypto -O0 -disable-O0-optnone -fexperimental-new-pass-manager -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s -check-prefixes=ARM,AArch64
 // RUN: %clang_cc1 -no-opaque-pointers -ffreestanding -triple aarch64-none-eabi -target-feature +v8.3a -O0 -disable-O0-optnone -fexperimental-new-pass-manager -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s -check-prefixes=ARM,AArch64,AArch6483
 // RUN: %clang_cc1 -no-opaque-pointers -ffreestanding -triple aarch64-none-eabi -target-feature +v8.5a -target-feature +rand -O0 -disable-O0-optnone -fexperimental-new-pass-manager -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s -check-prefixes=ARM,AArch64,AArch6483,AArch6485
 
Index: clang/test/CodeGen/aarch64-neon-sm4-sm3.c
===================================================================
--- clang/test/CodeGen/aarch64-neon-sm4-sm3.c
+++ clang/test/CodeGen/aarch64-neon-sm4-sm3.c
@@ -2,7 +2,7 @@
 // RUN:  -target-feature +sm4 -S -emit-llvm -o - %s \
 // RUN:  | FileCheck %s
 
-// RUN: not %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon \
+// RUN: not %clang_cc1 -std=c99 -triple aarch64-linux-gnu -target-feature +neon \
 // RUN: -S -emit-llvm -o - %s 2>&1 | FileCheck --check-prefix=CHECK-NO-CRYPTO %s
 
 // REQUIRES: aarch64-registered-target || arm-registered-target
Index: clang/test/CodeGen/aarch64-mops.c
===================================================================
--- clang/test/CodeGen/aarch64-mops.c
+++ clang/test/CodeGen/aarch64-mops.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops -target-feature +mte -w -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-MOPS   %s
-// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops                      -w -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-NOMOPS %s
-// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi                       -target-feature +mte -w -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-NOMOPS %s
-// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi                                            -w -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops -std=c99             -w -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -std=c99              -target-feature +mte -w -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -std=c99                                   -w -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-NOMOPS %s
 
 #include <arm_acle.h>
 #include <stddef.h>
Index: clang/test/CodeGen/X86/bmi2-builtins.c
===================================================================
--- clang/test/CodeGen/X86/bmi2-builtins.c
+++ clang/test/CodeGen/X86/bmi2-builtins.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +bmi2 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +bmi2 -emit-llvm -std=c99 -o - | FileCheck %s
 // RUN: %clang_cc1 -ffreestanding %s -triple=i386-apple-darwin -target-feature +bmi2 -emit-llvm -o - | FileCheck %s --check-prefix=B32
 
 
Index: clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c
===================================================================
--- clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c
+++ clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c
@@ -1,7 +1,7 @@
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +power8-vector -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +power8-vector -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-LE
-// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PPC
+// RUN: not %clang_cc1 -std=c99 -target-feature +altivec -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PPC
 // Added -target-feature +vsx above to avoid errors about "vector double" and to
 // generate the correct errors for functions that are only overloaded with VSX
 // (vec_cmpge, vec_cmple). Without this option, there is only one overload so
Index: clang/test/CodeGen/2008-10-13-FrontendCrash.c
===================================================================
--- clang/test/CodeGen/2008-10-13-FrontendCrash.c
+++ clang/test/CodeGen/2008-10-13-FrontendCrash.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o -
+// RUN: %clang_cc1 %s -std=c89 -emit-llvm -o -
 // PR2797
 
 unsigned int
Index: clang/test/CodeGen/2008-08-19-cast-of-typedef.c
===================================================================
--- clang/test/CodeGen/2008-08-19-cast-of-typedef.c
+++ clang/test/CodeGen/2008-08-19-cast-of-typedef.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -std=c89 -emit-llvm -o %t %s
 
 typedef short T[4];
 struct s {
Index: clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c
===================================================================
--- clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c
+++ clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s
+// RUN: %clang_cc1 -std=c89 -emit-llvm -o - %s
 // <rdar://problem/6108358>
 
 /* For posterity, the issue here begins initial "char []" decl for
Index: clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c
===================================================================
--- clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c
+++ clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -w -emit-llvm -o /dev/null %s
+// RUN: %clang_cc1 -std=c89 -w -emit-llvm -o /dev/null %s
 // PR2264.
 unsigned foo = 8L;
 unsigned bar = 0L;
Index: clang/test/CodeGen/2006-03-03-MissingInitializer.c
===================================================================
--- clang/test/CodeGen/2006-03-03-MissingInitializer.c
+++ clang/test/CodeGen/2006-03-03-MissingInitializer.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -std=c89 -o - | FileCheck %s
 
 struct X { int *XX; int Y;};
 
Index: clang/test/CodeGen/2006-01-13-StackSave.c
===================================================================
--- clang/test/CodeGen/2006-01-13-StackSave.c
+++ clang/test/CodeGen/2006-01-13-StackSave.c
@@ -1,5 +1,5 @@
 // PR691
-// RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers %s -std=c99 -emit-llvm -o - | FileCheck %s
 // CHECK: call i8* @llvm.stacksave()
 
 void test(int N) {
Index: clang/test/CodeGen/2005-01-02-VAArgError-ICE.c
===================================================================
--- clang/test/CodeGen/2005-01-02-VAArgError-ICE.c
+++ clang/test/CodeGen/2005-01-02-VAArgError-ICE.c
@@ -1,6 +1,6 @@
 // This file is erroneous, but should not cause the compiler to ICE.
 // PR481
-// RUN: %clang_cc1 %s -emit-llvm -o /dev/null
+// RUN: %clang_cc1 %s -std=c99 -emit-llvm -o /dev/null
 
 int flags(int a, int b, ...) {
         __builtin_va_list         args;
Index: clang/test/CodeGen/2005-01-02-ConstantInits.c
===================================================================
--- clang/test/CodeGen/2005-01-02-ConstantInits.c
+++ clang/test/CodeGen/2005-01-02-ConstantInits.c
@@ -1,5 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-globals --global-value-regex "@.+"
-// RUN: %clang_cc1 -no-opaque-pointers -triple=x86_64-unknown-linux %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -triple=x86_64-unknown-linux -std=c99 %s -emit-llvm -o - | FileCheck %s
 
 // This tests all kinds of hard cases with initializers and
 // array subscripts.  This corresponds to PR487.
Index: clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c
===================================================================
--- clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c
+++ clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c89 -emit-llvm %s -o - | FileCheck %s
 
 // There should not be an unresolved reference to func here.  Believe it or not,
 // the "expected result" is a function named 'func' which is internal and
Index: clang/test/CodeGen/2003-08-18-SigSetJmp.c
===================================================================
--- clang/test/CodeGen/2003-08-18-SigSetJmp.c
+++ clang/test/CodeGen/2003-08-18-SigSetJmp.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s  -o /dev/null
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c99 -emit-llvm %s  -o /dev/null
 
 #define _JBLEN ((9 * 2) + 3 + 16)
 typedef int sigjmp_buf[_JBLEN + 1];
Index: clang/test/CodeGen/2002-07-31-SubregFailure.c
===================================================================
--- clang/test/CodeGen/2002-07-31-SubregFailure.c
+++ clang/test/CodeGen/2002-07-31-SubregFailure.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s  -o /dev/null
+// RUN: %clang_cc1 -std=c99 -emit-llvm %s  -o /dev/null
 
 
 typedef union {
Index: clang/test/CodeGen/2002-07-14-MiscTests3.c
===================================================================
--- clang/test/CodeGen/2002-07-14-MiscTests3.c
+++ clang/test/CodeGen/2002-07-14-MiscTests3.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -w -emit-llvm %s  -o /dev/null
+// RUN: %clang_cc1 -std=c99 -w -emit-llvm %s  -o /dev/null
 
 void *malloc(unsigned);
 int puts(const char *s);
Index: clang/test/Analysis/plist-macros-with-expansion.c
===================================================================
--- clang/test/Analysis/plist-macros-with-expansion.c
+++ clang/test/Analysis/plist-macros-with-expansion.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core %s  \
+// RUN: %clang_analyze_cc1 -std=c99 -analyzer-checker=core %s  \
 // RUN:   -analyzer-output=plist -o %t.plist \
 // RUN:   -analyzer-config expand-macros=true -verify
 //
Index: clang/test/Analysis/novoidtypecrash.c
===================================================================
--- clang/test/Analysis/novoidtypecrash.c
+++ clang/test/Analysis/novoidtypecrash.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core %s
+// RUN: %clang_analyze_cc1 -std=c89 -analyzer-checker=core %s
 x;
 y(void **z) { // no-crash
   *z = x;
Index: clang/test/Analysis/misc-ps-region-store.m
===================================================================
--- clang/test/Analysis/misc-ps-region-store.m
+++ clang/test/Analysis/misc-ps-region-store.m
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class -Wno-strict-prototypes %s
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks   -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class -Wno-strict-prototypes %s
+// RUN: %clang_analyze_cc1 -std=c99 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class -Wno-strict-prototypes %s
+// RUN: %clang_analyze_cc1 -std=c99 -triple x86_64-apple-darwin9 -DTEST_64 -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks   -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class -Wno-strict-prototypes %s
 
 typedef long unsigned int size_t;
 void *memcpy(void *, const void *, size_t);
Index: clang/test/Analysis/diagnostics/no-store-func-path-notes.c
===================================================================
--- clang/test/Analysis/diagnostics/no-store-func-path-notes.c
+++ clang/test/Analysis/diagnostics/no-store-func-path-notes.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -w -x c -analyzer-checker=core -analyzer-output=text\
+// RUN: %clang_analyze_cc1 -w -std=c99 -analyzer-checker=core -analyzer-output=text\
 // RUN:     -verify %s
 
 typedef __typeof(sizeof(int)) size_t;
Index: clang/test/Analysis/PR49642.c
===================================================================
--- clang/test/Analysis/PR49642.c
+++ clang/test/Analysis/PR49642.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -w -verify %s \
+// RUN: %clang_analyze_cc1 -std=c99 -w -verify %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions
 
Index: clang/test/Analysis/ObjCProperties.m
===================================================================
--- clang/test/Analysis/ObjCProperties.m
+++ clang/test/Analysis/ObjCProperties.m
@@ -2,6 +2,7 @@
 // RUN:     -analyzer-checker=core,alpha.core,debug.ExprInspection
 
 #ifdef HEADER // A clever trick to avoid splitting up the test.
+extern void clang_analyzer_eval(int);
 
 @interface NSObject
 @end
Index: clang/test/Analysis/OSAtomic_mac.c
===================================================================
--- clang/test/Analysis/OSAtomic_mac.c
+++ clang/test/Analysis/OSAtomic_mac.c
@@ -1,6 +1,8 @@
 // RUN: %clang_analyze_cc1 -w -analyzer-checker=core,debug.ExprInspection \
 // RUN:                    -analyzer-output=text -verify %s
 
+extern void clang_analyzer_eval(int);
+
 int OSAtomicCompareAndSwapPtrBarrier(void *, void *, void **);
 int OSAtomicCompareAndSwapPtrBarrier(void *, void *, void **) {
   // There is some body in the actual header,
Index: clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
===================================================================
--- clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
+++ clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
@@ -86,6 +86,7 @@
 
 CF_IMPLICIT_BRIDGING_DISABLED
 
+extern CFTypeRef CFAutorelease(CFTypeRef cf);
 extern CFTypeRef CFMakeCollectable(CFTypeRef cf);
 typedef struct {
 }
Index: clang/test/ARCMT/objcmt-arc-cf-annotations.m
===================================================================
--- clang/test/ARCMT/objcmt-arc-cf-annotations.m
+++ clang/test/ARCMT/objcmt-arc-cf-annotations.m
@@ -80,6 +80,7 @@
 extern const CFAllocatorRef kCFAllocatorDefault;
 extern CFTypeRef CFRetain(CFTypeRef cf);
 extern void CFRelease(CFTypeRef cf);
+extern CFTypeRef CFAutorelease(CFTypeRef cf);
 extern CFTypeRef CFMakeCollectable(CFTypeRef cf);
 typedef struct {
 }
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2552,8 +2552,9 @@
     return ExprError();
 
   // This could be an implicitly declared function reference (legal in C90,
-  // extension in C99, forbidden in C++).
-  if (R.empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
+  // extension in C99, forbidden in C++ and C2x).
+  if (R.empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus &&
+      !getLangOpts().C2x) {
     NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
     if (D) R.addDecl(D);
   }
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -931,9 +931,12 @@
       //
       //   appeared.
       //
-      // We also allow this in C99 as an extension.
-      if (NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *Name, S))
-        return NameClassification::NonType(D);
+      // We also allow this in C99 as an extension. However, this is not
+      // allowed in C2x as there are no functions without prototypes there.
+      if (!getLangOpts().C2x) {
+        if (NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *Name, S))
+          return NameClassification::NonType(D);
+      }
     }
 
     if (getLangOpts().CPlusPlus20 && SS.isEmpty() && NextToken.is(tok::less)) {
@@ -15194,6 +15197,9 @@
 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
 NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
                                           IdentifierInfo &II, Scope *S) {
+  // It is not valid to implicitly define a function in C2x.
+  assert(!LangOpts.C2x && "Cannot implicitly define a function in C2x");
+
   // Find the scope in which the identifier is injected and the corresponding
   // DeclContext.
   // FIXME: C89 does not say what happens if there is no enclosing block scope.
@@ -15239,8 +15245,10 @@
   // OpenCL v2.0 s6.9.u - Implicit function declaration is not supported.
   else if (getLangOpts().OpenCL)
     diag_id = diag::err_opencl_implicit_function_decl;
+  else if (getLangOpts().C11)
+    diag_id = diag::ext_implicit_function_decl_c11;
   else if (getLangOpts().C99)
-    diag_id = diag::ext_implicit_function_decl;
+    diag_id = diag::ext_implicit_function_decl_c99;
   else
     diag_id = diag::warn_implicit_function_decl;
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -417,9 +417,13 @@
 def warn_implicit_function_decl : Warning<
   "implicit declaration of function %0">,
   InGroup<ImplicitFunctionDeclare>, DefaultIgnore;
-def ext_implicit_function_decl : ExtWarn<
+def ext_implicit_function_decl_c99 : ExtWarn<
   "implicit declaration of function %0 is invalid in C99">,
   InGroup<ImplicitFunctionDeclare>;
+def ext_implicit_function_decl_c11 : ExtWarn<
+  "implicit declaration of function %0 is invalid in C99 and later and "
+  "unsupported in C2x">,
+  InGroup<ImplicitFunctionDeclare>, DefaultError;
 def note_function_suggestion : Note<"did you mean %0?">;
 
 def err_ellipsis_first_param : Error<
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -138,6 +138,12 @@
   cases where the deprecated declarations or definitions of a function without
   a prototype will change behavior in C2x. This diagnostic is grouped under the
   ``-Wstrict-prototypes`` warning group, but is enabled by default.
+- The ``-Wimplicit-function-declaration`` warning diagnostic now defaults to
+  emitting an error (which can be downgraded to a warning with
+  ``-Wno-error=implicit-function-declaration`` or disabled entirely with
+  ``-Wno-implicit-function-declaration``) in C11 and
+  C17 mode. This is because the feature was removed in C99 and cannot be
+  supported in C2x.
 
 Non-comprehensive list of changes in this release
 -------------------------------------------------
@@ -208,6 +214,9 @@
 - Implemented `WG14 N2775 Literal suffixes for bit-precise integers <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2775.pdf>`_.
 - Implemented the `*_WIDTH` macros to complete support for
   `WG14 N2412 Two's complement sign representation for C2x <https://www9.open-std.org/jtc1/sc22/wg14/www/docs/n2412.pdf>`_.
+- Removed support for implicit function declarations. This was a C89 feature
+  that was removed in C99, but cannot be supported in C2x because it requires
+  support for functions without prototypes, which no longer exist in C2x.
 
 C++ Language Changes in Clang
 -----------------------------
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
@@ -7,7 +7,7 @@
 // RUN:     {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 1}, \
 // RUN:     {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 0}, \
 // RUN:     {key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold, value: 0} \
-// RUN:  ]}' --
+// RUN:  ]}' -- -std=c89
 
 void implicitDoesntBreakOtherStuff(int A, int B) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: 2 adjacent parameters of 'implicitDoesntBreakOtherStuff' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1369,6 +1369,7 @@
   Annotations Test("void x() { [[foo]](); }");
   auto TU = TestTU::withCode(Test.code());
   TU.Filename = "test.c";
+  TU.ExtraArgs.push_back("-std=c99");
 
   Symbol Sym = func("foo");
   Sym.Flags |= Symbol::IndexedForCodeCompletion;
Index: clang-tools-extra/clangd/ParsedAST.cpp
===================================================================
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -428,7 +428,8 @@
     // this is an error. (The actual typo correction is nice too).
     // We restore the original severity in the level adjuster.
     // FIXME: It would be better to have a real API for this, but what?
-    for (auto ID : {diag::ext_implicit_function_decl,
+    for (auto ID : {diag::ext_implicit_function_decl_c99,
+                    diag::ext_implicit_function_decl_c11,
                     diag::warn_implicit_function_decl}) {
       OverriddenSeverity.try_emplace(
           ID, Clang->getDiagnostics().getDiagnosticLevel(ID, SourceLocation()));
Index: clang-tools-extra/clangd/IncludeFixer.cpp
===================================================================
--- clang-tools-extra/clangd/IncludeFixer.cpp
+++ clang-tools-extra/clangd/IncludeFixer.cpp
@@ -197,7 +197,8 @@
   case diag::err_no_member_template:
   case diag::err_no_member_template_suggest:
   case diag::warn_implicit_function_decl:
-  case diag::ext_implicit_function_decl:
+  case diag::ext_implicit_function_decl_c99:
+  case diag::ext_implicit_function_decl_c11:
   case diag::err_opencl_implicit_function_decl:
     dlog("Unresolved name at {0}, last typo was {1}",
          Info.getLocation().printToString(Info.getSourceManager()),
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to