Skip to content

Conversation

@Meinersbur
Copy link

Just printing "condition" is useless. Actually print the condition being tested.

Before:

[header test_target_map_components_default.F90:111]  Condition condition failed

After:

[header test_target_map_components_default.F90:110]  Condition .NOT. ASSOCIATED(myStruct(i). yPtr, justATarget) failed

Just printing "condition" is useless. Actually print the condition being tested.

Before:
[header test_target_map_components_default.F90:111]  Condition condition failed

After:
[header test_target_map_components_default.F90:110]  Condition .NOT. ASSOCIATED(myStruct(i). yPtr, justATarget) failed
@spophale
Copy link
Collaborator

spophale commented Dec 4, 2025

@andrewkallai , can you test this ?

Copy link
Collaborator

@andrewkallai andrewkallai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will not compile when compiling with gfortran

/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:30:73:

   30 |         OMPVV_TEST_VERBOSE(test_map_derived_type_default() .ne. 0)
      |                                                                         1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:31:79:

   31 |         OMPVV_TEST_VERBOSE(test_map_derived_type_default_array() .ne. 0)
      |                                                                               1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:63:59:

   63 |             OMPVV_TEST_VERBOSE(cpyStruct%myInt /= 5)
      |                                                           1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:64:74:

   64 |             OMPVV_TEST_VERBOSE(cpyStruct%myStr .NE. 'there you go')
      |                                                                          1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:65:78:

   65 |             OMPVV_TEST_VERBOSE(ABS(cpyStruct%myReal - 4.4) .GT. 0.0001)
      |                                                                              1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:66:65:

   66 |             OMPVV_TEST_VERBOSE(ANY(cpyStruct%myArr /= 10))
      |                                                                 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:67:84:

   67 |             OMPVV_TEST_VERBOSE(.NOT. ASSOCIATED(myStruct%myPtr, justATarget))
      |                                                                                    1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:68:85:

   68 |             OMPVV_TEST_VERBOSE(.NOT. ASSOCIATED(cpyStruct%myPtr, justATarget))
      |                                                                                     1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:106:64:

  106 |               OMPVV_TEST_VERBOSE(cpyStruct(i)%myInt /= 5)
      |                                                                1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:107:79:

  107 |               OMPVV_TEST_VERBOSE(cpyStruct(i)%myStr .NE. 'there you go')
      |                                                                               1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:108:83:

  108 |               OMPVV_TEST_VERBOSE(ABS(cpyStruct(i)%myReal - 4.4) .GT. 0.0001)
      |                                                                                   1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:109:70:

  109 |               OMPVV_TEST_VERBOSE(ANY(cpyStruct(i)%myArr /= 10))
      |                                                                      1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:110:89:

  110 |               OMPVV_TEST_VERBOSE(.NOT. ASSOCIATED(myStruct(i)%myPtr, justATarget))
      |                                                                                         1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:111:90:

  111 |               OMPVV_TEST_VERBOSE(.NOT. ASSOCIATED(cpyStruct(i)%myPtr, justATarget))
      |                                                                                          1
Error: Syntax error in argument list at (1)

As such, a preprocessor conitional has to be added to check if gfortran is being used.


! Macro for testing for errors
#define OMPVV_TEST_VERBOSE(condition) call test_error_verbose(condition, "condition", __FILENAME__, __LINE__)
#define OMPVV_TEST_VERBOSE(condition) call test_error_verbose(condition, #condition, __FILENAME__, __LINE__)
Copy link
Collaborator

@andrewkallai andrewkallai Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define OMPVV_TEST_VERBOSE(condition) call test_error_verbose(condition, #condition, __FILENAME__, __LINE__)
#ifdef __GFORTRAN__
#define STR(x) "x"
#define OMPVV_TEST_VERBOSE(condition) call test_error_verbose(condition, STR(condition), __FILENAME__, __LINE__)
#else
#define OMPVV_TEST_VERBOSE(condition) call test_error_verbose(condition, #condition, __FILENAME__, __LINE__)
#endif

Copy link
Collaborator

@andrewkallai andrewkallai Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change line 86 to

#ifdef __GFORTRAN__
#define STR(x) "x"
#define OMPVV_TEST_AND_SET_VERBOSE(err, condition) err = err + test_and_set_verbose(condition, STR(condition), __FILENAME__, __LINE__)
#else
#define OMPVV_TEST_AND_SET_VERBOSE(err, condition) err = err + test_and_set_verbose(condition, #condition, __FILENAME__, __LINE__)
#endif

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewkallai Can you try whether changing #condition to "condition " #condition works for gfortran and other compilers? The preprocessor is supposed to expand #condition to the value of condition wrapped in double quotes, and then the resulting constant is concatenated with the adjacent string constant. As I know the concatenation is optional, but let's try whether this trick works or not.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GNU cpp's manual suggests a way to stringize using the traditional cpp:
image

It indeed seems to work: https://godbolt.org/z/jWKGrnffc

@andrewkallai andrewkallai added the bug fix Fixes a bug in a test or the suite label Dec 18, 2025
@Meinersbur
Copy link
Author

Meinersbur commented Jan 5, 2026

Updated PR to supprot GFortran's traditional cpp.

Instead of __GFORTRAN__, it is possible to detect the traditional cpp using some behaviour detection:

#define suffix(x) foo_/**/x
#define foo_bar 1
#define foo_
#define bar 0

#if suffix(bar)
    Running in Traditional Mode
#else
    Running in Standard Mode
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix Fixes a bug in a test or the suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants