Re: [Mesa-dev] [PATCH] glsl: Fixup glcpp tests for redefining a macro with whitespace changes.

2014-06-17 Thread Erik Faye-Lund
On Thu, Jun 12, 2014 at 3:11 AM, Carl Worth cwo...@cworth.org wrote:
 Previously, the test suite was expecting the compiler to allow a redefintion
 of a macro with whitespace added, but gcc is more strict and allows only for
 changes in the amounts of whitespace, (but insists that whitespace exist or
 not in exactly the same places).

 See: https://gcc.gnu.org/onlinedocs/cpp/Undefining-and-Redefining-Macros.html:

  These definitions are effectively the same:

   #define FOUR (2 + 2)
   #define FOUR (2+2)
   #define FOUR (2 /* two */ + 2)

  but these are not:

   #define FOUR (2 + 2)
   #define FOUR ( 2+2 )
   #define FOUR (2 * 2)
   #define FOUR(score,and,seven,years,ago) (2 + 2)

 This change adjusts the existing redefine-macro-legitimate test to work with
 the more strict understanding, and adds a new redefine-whitespace test to
 verify that changes in the position of whitespace are flagged as errors.

You may want to quote the relevant part from the C++ spec (16.3 Macro
replacement, [cpp.replace]):

Two replacement lists are identical if and only if the preprocessing
tokens in both have the same number, ordering, spelling, and
white-space separation, where all white-space separations are
considered identical.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl: Fixup glcpp tests for redefining a macro with whitespace changes.

2014-06-16 Thread Anuj Phogat
On Wed, Jun 11, 2014 at 6:11 PM, Carl Worth cwo...@cworth.org wrote:
 Previously, the test suite was expecting the compiler to allow a redefintion
 of a macro with whitespace added, but gcc is more strict and allows only for
 changes in the amounts of whitespace, (but insists that whitespace exist or
 not in exactly the same places).

 See: https://gcc.gnu.org/onlinedocs/cpp/Undefining-and-Redefining-Macros.html:

  These definitions are effectively the same:

   #define FOUR (2 + 2)
   #define FOUR (2+2)
   #define FOUR (2 /* two */ + 2)

  but these are not:

   #define FOUR (2 + 2)
   #define FOUR ( 2+2 )
   #define FOUR (2 * 2)
   #define FOUR(score,and,seven,years,ago) (2 + 2)

 This change adjusts the existing redefine-macro-legitimate test to work with
 the more strict understanding, and adds a new redefine-whitespace test to
 verify that changes in the position of whitespace are flagged as errors.
 ---
  .../glcpp/tests/088-redefine-macro-legitimate.c|  2 +-
  src/glsl/glcpp/tests/122-redefine-whitespace.c | 16 +++
  .../glcpp/tests/122-redefine-whitespace.c.expected | 23 
 ++
  3 files changed, 40 insertions(+), 1 deletion(-)
  create mode 100644 src/glsl/glcpp/tests/122-redefine-whitespace.c
  create mode 100644 src/glsl/glcpp/tests/122-redefine-whitespace.c.expected

 diff --git a/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c 
 b/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c
 index 0e0666b..422c654 100644
 --- a/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c
 +++ b/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c
 @@ -1,5 +1,5 @@
  #define abc 123
  #define abc 123

 -#define foo(x) (x)+23
  #define foo(x) ( x ) + 23
 +#define foo(x) (  x  )  +  23
 diff --git a/src/glsl/glcpp/tests/122-redefine-whitespace.c 
 b/src/glsl/glcpp/tests/122-redefine-whitespace.c
 new file mode 100644
 index 000..ae7ea09
 --- /dev/null
 +++ b/src/glsl/glcpp/tests/122-redefine-whitespace.c
 @@ -0,0 +1,16 @@
 +/* Original definitions. */
 +#define TWO  ( 1+1 )
 +#define FOUR (2 + 2)
 +#define SIX  (3 + 3)
 +
 +/* Redefinitions with whitespace in same places, but different amounts, (so 
 no
 + * error). */
 +#define TWO(   1+1   )
 +#define FOUR(2 +  2)
 +#define SIX(3/*comment is whitespace*/+   /* collapsed */ /* to */ /* 
 one */ /* space */  3)
 +
 +/* Redefinitions with whitespace in different places. Each of these should
 + * trigger an error. */
 +#define TWO  (1 + 1)
 +#define FOUR ( 2+2 )
 +#define SIX  (/*not*/3 + 3/*expected*/)
 diff --git a/src/glsl/glcpp/tests/122-redefine-whitespace.c.expected 
 b/src/glsl/glcpp/tests/122-redefine-whitespace.c.expected
 new file mode 100644
 index 000..193ebc4
 --- /dev/null
 +++ b/src/glsl/glcpp/tests/122-redefine-whitespace.c.expected
 @@ -0,0 +1,23 @@
 +0:14(9): preprocessor error: Redefinition of macro TWO
 +
 +0:15(9): preprocessor error: Redefinition of macro FOUR
 +
 +0:16(9): preprocessor error: Redefinition of macro SIX
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 --
 2.0.0

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reviewed-by: Anuj Phogat anuj.pho...@gmail.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] glsl: Fixup glcpp tests for redefining a macro with whitespace changes.

2014-06-11 Thread Carl Worth
Previously, the test suite was expecting the compiler to allow a redefintion
of a macro with whitespace added, but gcc is more strict and allows only for
changes in the amounts of whitespace, (but insists that whitespace exist or
not in exactly the same places).

See: https://gcc.gnu.org/onlinedocs/cpp/Undefining-and-Redefining-Macros.html:

 These definitions are effectively the same:

  #define FOUR (2 + 2)
  #define FOUR (2+2)
  #define FOUR (2 /* two */ + 2)

 but these are not:

  #define FOUR (2 + 2)
  #define FOUR ( 2+2 )
  #define FOUR (2 * 2)
  #define FOUR(score,and,seven,years,ago) (2 + 2)

This change adjusts the existing redefine-macro-legitimate test to work with
the more strict understanding, and adds a new redefine-whitespace test to
verify that changes in the position of whitespace are flagged as errors.
---
 .../glcpp/tests/088-redefine-macro-legitimate.c|  2 +-
 src/glsl/glcpp/tests/122-redefine-whitespace.c | 16 +++
 .../glcpp/tests/122-redefine-whitespace.c.expected | 23 ++
 3 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 src/glsl/glcpp/tests/122-redefine-whitespace.c
 create mode 100644 src/glsl/glcpp/tests/122-redefine-whitespace.c.expected

diff --git a/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c 
b/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c
index 0e0666b..422c654 100644
--- a/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c
+++ b/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c
@@ -1,5 +1,5 @@
 #define abc 123
 #define abc 123
 
-#define foo(x) (x)+23
 #define foo(x) ( x ) + 23
+#define foo(x) (  x  )  +  23
diff --git a/src/glsl/glcpp/tests/122-redefine-whitespace.c 
b/src/glsl/glcpp/tests/122-redefine-whitespace.c
new file mode 100644
index 000..ae7ea09
--- /dev/null
+++ b/src/glsl/glcpp/tests/122-redefine-whitespace.c
@@ -0,0 +1,16 @@
+/* Original definitions. */
+#define TWO  ( 1+1 )
+#define FOUR (2 + 2)
+#define SIX  (3 + 3)
+
+/* Redefinitions with whitespace in same places, but different amounts, (so no
+ * error). */
+#define TWO(   1+1   )
+#define FOUR(2 +  2)
+#define SIX(3/*comment is whitespace*/+   /* collapsed */ /* to */ /* one 
*/ /* space */  3)
+
+/* Redefinitions with whitespace in different places. Each of these should
+ * trigger an error. */
+#define TWO  (1 + 1)
+#define FOUR ( 2+2 )
+#define SIX  (/*not*/3 + 3/*expected*/)
diff --git a/src/glsl/glcpp/tests/122-redefine-whitespace.c.expected 
b/src/glsl/glcpp/tests/122-redefine-whitespace.c.expected
new file mode 100644
index 000..193ebc4
--- /dev/null
+++ b/src/glsl/glcpp/tests/122-redefine-whitespace.c.expected
@@ -0,0 +1,23 @@
+0:14(9): preprocessor error: Redefinition of macro TWO
+
+0:15(9): preprocessor error: Redefinition of macro FOUR
+
+0:16(9): preprocessor error: Redefinition of macro SIX
+
+ 
+
+
+
+
+ 
+
+
+
+
+
+ 
+
+
+
+
+
-- 
2.0.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev