diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-01-22 23:07:19 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-01-22 23:07:19 +0000 |
| commit | 8c7bd6ac1a32e667d3f57682d6c0f3e4e6c7a97f (patch) | |
| tree | 6c6c070d3beaf298981f9d1266408aa6940e5aad | |
| parent | a5adf489b74dc8cc90340d0c304e30346dcf5cf2 (diff) | |
| download | bcm5719-llvm-8c7bd6ac1a32e667d3f57682d6c0f3e4e6c7a97f.tar.gz bcm5719-llvm-8c7bd6ac1a32e667d3f57682d6c0f3e4e6c7a97f.zip | |
Don't forget about a builtin if we're about to redeclare it and we couldn't
create an implicit declaration of it (because some type it depends on is
unavailable). This had the effect of causing us to not implicitly give it the
right attributes. It turns out that glibc's __sigsetjmp is declared before
sigjmp_buf is declared, and this resulted in us not implicitly giving it
__attribute__((returns_twice)), which in turn resulted in miscompiles in any C
code calling glibc's sigsetjmp.
(See also the vaguely-related sourceware.org/PR4662.)
llvm-svn: 199850
| -rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 8 | ||||
| -rw-r--r-- | clang/test/Sema/implicit-builtin-decl.c | 9 |
2 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 0f5a78b10a1..01220769e32 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -545,14 +545,6 @@ static bool LookupBuiltin(Sema &S, LookupResult &R) { R.addDecl(D); return true; } - - if (R.isForRedeclaration()) { - // If we're redeclaring this function anyway, forget that - // this was a builtin at all. - S.Context.BuiltinInfo.ForgetBuiltin(BuiltinID, S.Context.Idents); - } - - return false; } } } diff --git a/clang/test/Sema/implicit-builtin-decl.c b/clang/test/Sema/implicit-builtin-decl.c index d7ec16953a0..2a7a7ca27b6 100644 --- a/clang/test/Sema/implicit-builtin-decl.c +++ b/clang/test/Sema/implicit-builtin-decl.c @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: not %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s + void f() { int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring library function 'malloc' with type}} \ // expected-note{{please include the header <stdlib.h> or explicitly provide a declaration for 'malloc'}} \ @@ -57,3 +59,10 @@ void snprintf() { } void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires inclusion of the header <setjmp.h>}} extern float fmaxf(float, float); + +struct __jmp_buf_tag {}; +void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires inclusion of the header <setjmp.h>}} + +// CHECK: FunctionDecl {{.*}} <line:[[@LINE-2]]:1, col:44> sigsetjmp ' +// CHECK-NOT: FunctionDecl +// CHECK: ReturnsTwiceAttr {{.*}} <{{.*}}> Implicit |

