[PATCH] PR20958: Allow __builtin_isnan to be declared.

Charlie Turner charlie.turner at arm.com
Thu Apr 23 05:31:26 PDT 2015


Before this patch, a builtin which takes only a variadic argument,
such as,
    
int __builtin_isnan(...);
    
Was actually getting declared as,
    
int __builtin_isnan();

This was causing several problem, one is described in PR20958. The
special-casing of this variadic argument has been removed. It
uncovered MS's __noop builtin was incorrectly handled. We don't care
about the semantics of those arguments, so the builtin definition for
it has been updated as such.

A further wart exposed here was the declaration of vfprintf to appease
autoconf. That has been reverted. What was once an error about
requiring inclusion of a header has now been downgraded to a warning,
so the reason for that fix is no longer valid. See PR4290 and r72760.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9216

Files:
  include/clang/Basic/Builtins.def
  lib/AST/ASTContext.cpp
  test/Sema/vfprintf-invalid-redecl.c
  test/Sema/vfprintf-valid-redecl.c

Index: include/clang/Basic/Builtins.def
===================================================================
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -710,7 +710,7 @@
 LANGBUILTIN(_InterlockedExchange,        "LiLiD*Li",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangePointer, "v*v*D*v*",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedIncrement,       "LiLiD*",     "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(__noop,           "i.",  "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__noop,           "i.",  "nt", ALL_MS_LANGUAGES)
 LANGBUILTIN(__readfsdword,    "ULiULi", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__va_start,       "vc**.", "nt", ALL_MS_LANGUAGES)
 
@@ -753,7 +753,7 @@
 LIBBUILTIN(snprintf, "ic*zcC*.",  "fp:2:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(sprintf, "ic*cC*.",    "fp:1:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vprintf, "icC*a",      "fP:0:", "stdio.h", ALL_LANGUAGES)
-LIBBUILTIN(vfprintf, "i.",        "fP:1:", "stdio.h", ALL_LANGUAGES)
+LIBBUILTIN(vfprintf, "iP*cC*a",   "fP:1:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vsnprintf, "ic*zcC*a", "fP:2:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vsprintf, "ic*cC*a",   "fP:1:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(scanf, "icC*R.",       "fs:0:", "stdio.h", ALL_LANGUAGES)
Index: lib/AST/ASTContext.cpp
===================================================================
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -7859,10 +7859,6 @@
 
   bool Variadic = (TypeStr[0] == '.');
 
-  // We really shouldn't be making a no-proto type here, especially in C++.
-  if (ArgTypes.empty() && Variadic)
-    return getFunctionNoProtoType(ResType, EI);
-
   FunctionProtoType::ExtProtoInfo EPI;
   EPI.ExtInfo = EI;
   EPI.Variadic = Variadic;
Index: test/Sema/vfprintf-invalid-redecl.c
===================================================================
--- test/Sema/vfprintf-invalid-redecl.c
+++ 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' requires inclusion of the header <stdio.h>}}
Index: test/Sema/vfprintf-valid-redecl.c
===================================================================
--- test/Sema/vfprintf-valid-redecl.c
+++ test/Sema/vfprintf-valid-redecl.c
@@ -1,6 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
-// RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify -DPREDECLARE
-// expected-no-diagnostics
+// RUN: %clang_cc1 %s -fsyntax-only -pedantic -DPREDECLARE
 
 #ifdef PREDECLARE
 // PR16344
@@ -11,6 +10,5 @@
 #endif
 
 // PR4290
-// The following declaration is compatible with vfprintf, so we shouldn't
-// warn.
-int vfprintf();
+// The following declaration is compatible with vfprintf, so it should not be an error.
+int vfprintf(); // expected-warning {{declaration of built-in function 'vfprintf' requires inclusion of the header <stdio.h>}}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9216.24288.patch
Type: text/x-patch
Size: 3164 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150423/2e6d7357/attachment.bin>


More information about the cfe-commits mailing list