diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-12-19 23:59:34 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-12-19 23:59:34 +0000 |
commit | 836de6babb7846e08476988c8b2cf3ced0b09a1e (patch) | |
tree | eec032705d2c271fe0d7abbc5e71f9b40a9303f8 /clang/test | |
parent | ebfc2f90d0a12eac664e5978de905e09ca483b2f (diff) | |
download | bcm5719-llvm-836de6babb7846e08476988c8b2cf3ced0b09a1e.tar.gz bcm5719-llvm-836de6babb7846e08476988c8b2cf3ced0b09a1e.zip |
Fix completely bogus types for some builtins:
* In C++, never create a FunctionNoProtoType for a builtin (fixes C++1z
crasher from r289754).
* Fix type of __sync_synchronize to be a no-parameter function rather than a
varargs function. This matches GCC.
* Fix type of vfprintf to match its actual type. We gave it a wrong type due
to PR4290 (apparently autoconf generates invalid code and expects compilers
to choke it down or it miscompiles the program; the relevant error in clang
was downgraded to a warning in r122744 to fix other occurrences of this
autoconf brokenness, so we don't need this workaround any more).
* Turn off vararg argument checking for __noop, since it's not *really* a
varargs function. Alternatively we could add custom type checking for it
and synthesize parameter types matching the actual arguments in each call,
but that seemed like overkill.
llvm-svn: 290146
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Sema/vfprintf-invalid-redecl.c | 2 | ||||
-rw-r--r-- | clang/test/Sema/vfprintf-valid-redecl.c | 8 | ||||
-rw-r--r-- | clang/test/SemaCXX/builtins.cpp | 11 |
3 files changed, 16 insertions, 5 deletions
diff --git a/clang/test/Sema/vfprintf-invalid-redecl.c b/clang/test/Sema/vfprintf-invalid-redecl.c index cbf47a69a9a..f06b1b6d214 100644 --- a/clang/test/Sema/vfprintf-invalid-redecl.c +++ b/clang/test/Sema/vfprintf-invalid-redecl.c @@ -3,4 +3,4 @@ // The following declaration is not compatible with vfprintf(), but make // sure this isn't an error: autoconf expects this to build. -char vfprintf(); // expected-warning {{incompatible redeclaration of library function 'vfprintf'}} expected-note {{'vfprintf' is a builtin}} +char vfprintf(); // expected-warning {{declaration of built-in function 'vfprintf'}} diff --git a/clang/test/Sema/vfprintf-valid-redecl.c b/clang/test/Sema/vfprintf-valid-redecl.c index 8ed18786ab7..eb5c4d33071 100644 --- a/clang/test/Sema/vfprintf-valid-redecl.c +++ b/clang/test/Sema/vfprintf-valid-redecl.c @@ -1,16 +1,18 @@ // RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify // RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify -DPREDECLARE -// expected-no-diagnostics #ifdef PREDECLARE // PR16344 // Clang has defined 'vfprint' in builtin list. If the following line occurs before any other // `vfprintf' in this file, and we getPreviousDecl()->getTypeSourceInfo() on it, then we will // get a null pointer since the one in builtin list doesn't has valid TypeSourceInfo. -int vfprintf(void) { return 0; } +int vfprintf(void) { return 0; } // expected-warning {{requires inclusion of the header <stdio.h>}} #endif // PR4290 // The following declaration is compatible with vfprintf, so we shouldn't -// warn. +// reject. int vfprintf(); +#ifndef PREDECLARE +// expected-warning@-2 {{requires inclusion of the header <stdio.h>}} +#endif diff --git a/clang/test/SemaCXX/builtins.cpp b/clang/test/SemaCXX/builtins.cpp index 69bdfa61451..f26931b55bd 100644 --- a/clang/test/SemaCXX/builtins.cpp +++ b/clang/test/SemaCXX/builtins.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11 +// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11 -fcxx-exceptions +// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++1z -fcxx-exceptions typedef const struct __CFString * CFStringRef; #define CFSTR __builtin___CFStringMakeConstantString @@ -44,3 +45,11 @@ void no_ms_builtins() { __noop(1); // expected-error {{use of undeclared}} __debugbreak(); // expected-error {{use of undeclared}} } + +struct FILE; +extern "C" int vfprintf(FILE *__restrict, const char *__restrict, + __builtin_va_list va); + +void synchronize_args() { + __sync_synchronize(0); // expected-error {{too many arguments}} +} |