Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 May 2013 15:29:35 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r250566 - in head/contrib: gcc gcclibs/libcpp gcclibs/libcpp/include
Message-ID:  <201305121529.r4CFTZ0w056586@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Sun May 12 15:29:35 2013
New Revision: 250566
URL: http://svnweb.freebsd.org/changeset/base/250566

Log:
  Add support for "d" floating-point suffix, as defined by draft N1312
  of TR 24732. Emit pedantic warning if the feature is being used.
  
  Should solve GCC bug 39027.
  
  Obtained from:	OpenBSD
  MFC after:	2 weeks

Modified:
  head/contrib/gcc/c-lex.c
  head/contrib/gcclibs/libcpp/expr.c
  head/contrib/gcclibs/libcpp/include/cpplib.h

Modified: head/contrib/gcc/c-lex.c
==============================================================================
--- head/contrib/gcc/c-lex.c	Sun May 12 15:23:59 2013	(r250565)
+++ head/contrib/gcc/c-lex.c	Sun May 12 15:29:35 2013	(r250566)
@@ -640,6 +640,13 @@ interpret_float (const cpp_token *token,
   char *copy;
   size_t copylen;
 
+  /* Default (no suffix) is double.  */
+  if (flags & CPP_N_DEFAULT)
+    {
+      flags ^= CPP_N_DEFAULT;
+      flags |= CPP_N_MEDIUM;
+    }
+
   /* Decode type based on width and properties. */
   if (flags & CPP_N_DFLOAT)
     if ((flags & CPP_N_WIDTH) == CPP_N_LARGE)

Modified: head/contrib/gcclibs/libcpp/expr.c
==============================================================================
--- head/contrib/gcclibs/libcpp/expr.c	Sun May 12 15:23:59 2013	(r250565)
+++ head/contrib/gcclibs/libcpp/expr.c	Sun May 12 15:29:35 2013	(r250566)
@@ -82,7 +82,7 @@ static void check_promotion (cpp_reader 
 static unsigned int
 interpret_float_suffix (const uchar *s, size_t len)
 {
-  size_t f = 0, l = 0, i = 0, d = 0;
+  size_t f = 0, l = 0, i = 0, d = 0, d0 = 0;
 
   while (len--)
     switch (s[len])
@@ -101,7 +101,12 @@ interpret_float_suffix (const uchar *s, 
 	return 0;
       }
 
-  if (f + l > 1 || i > 1)
+  if (d == 1 && !f && !l) {
+    d = 0;
+    d0 = 1;
+  }
+
+  if (f + d0 + l > 1 || i > 1)
     return 0;
 
   /* Allow dd, df, dl suffixes for decimal float constants.  */
@@ -110,7 +115,8 @@ interpret_float_suffix (const uchar *s, 
 
   return ((i ? CPP_N_IMAGINARY : 0)
 	  | (f ? CPP_N_SMALL :
-	     l ? CPP_N_LARGE : CPP_N_MEDIUM)
+	     d0 ? CPP_N_MEDIUM :
+	     l ? CPP_N_LARGE : CPP_N_DEFAULT)
 	  | (d ? CPP_N_DFLOAT : 0));
 }
 
@@ -261,6 +267,13 @@ cpp_classify_number (cpp_reader *pfile, 
 		   "traditional C rejects the \"%.*s\" suffix",
 		   (int) (limit - str), str);
 
+      /* A suffix for double is a GCC extension via decimal float support.
+	 If the suffix also specifies an imaginary value we'll catch that
+	 later.  */
+      if ((result == CPP_N_MEDIUM) && CPP_PEDANTIC (pfile))
+	cpp_error (pfile, CPP_DL_PEDWARN,
+		   "suffix for double constant is a GCC extension");
+
       /* Radix must be 10 for decimal floats.  */
       if ((result & CPP_N_DFLOAT) && radix != 10)
         {

Modified: head/contrib/gcclibs/libcpp/include/cpplib.h
==============================================================================
--- head/contrib/gcclibs/libcpp/include/cpplib.h	Sun May 12 15:23:59 2013	(r250565)
+++ head/contrib/gcclibs/libcpp/include/cpplib.h	Sun May 12 15:29:35 2013	(r250566)
@@ -749,6 +749,7 @@ struct cpp_num
 #define CPP_N_UNSIGNED	0x1000	/* Properties.  */
 #define CPP_N_IMAGINARY	0x2000
 #define CPP_N_DFLOAT	0x4000
+#define CPP_N_DEFAULT	0x8000
 
 /* Classify a CPP_NUMBER token.  The return value is a combination of
    the flags from the above sets.  */
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305121529.r4CFTZ0w056586>