Bug 47040 - Make error message for empty array constructor more helpful/correct
Summary: Make error message for empty array constructor more helpful/correct
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P5 enhancement
Target Milestone: ---
Assignee: Dominique d'Humieres
URL:
Keywords: diagnostic, patch
Depends on:
Blocks:
 
Reported: 2010-12-22 10:06 UTC by Tobias Burnus
Modified: 2016-04-09 18:05 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-06-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-12-22 10:06:29 UTC
Found at http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/3f6348b03eaed435

The error message:

     call print( [ ] )
                    1
Error: Empty array constructor at (1) is not allowed

is misleading at only empty array constructors without typespec are invalid. Thus, the following is valid:
     call print( [ real :: ] )


Expect: Error message:
 "Error: Empty array constructor at (1) is not allowed without type-spec"
or
 "Error: Empty array constructor without type-spec at (1) is not allowed"


F2008:

R468 array-constructor is (/ ac-spec /)
                       or lbracket ac-spec rbracket
R469 ac-spec is type-spec ::
             or [type-spec ::] ac-value-list

"An empty sequence forms a zero-sized array."
Comment 1 Tobias Burnus 2010-12-22 10:16:56 UTC
Draft patch - feel free to take it, I am not sure when I have the time to submit it.

--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -1054,7 +1054,8 @@ gfc_match_array_constructor (gfc_expr **result)
        goto done;
       else
        {
-         gfc_error ("Empty array constructor at %C is not allowed");
+         gfc_error ("Empty array constructor without type-spec at %C is not "
+                    "allowed");
          goto cleanup;
        }
     }
Comment 2 Dominique d'Humieres 2013-06-26 19:06:22 UTC
Still there two years and a half later at revision 200429. What is wrong with the patch in comment #1?
Comment 3 Tobias Burnus 2013-06-26 20:07:12 UTC
(In reply to Dominique d'Humieres from comment #2)
> Still there two years and a half later at revision 200429. What is wrong
> with the patch in comment #1?

Nothing - it just needs to be packaged.
Comment 4 Dominique d'Humieres 2013-06-26 20:43:13 UTC
> Nothing - it just needs to be packaged.

Do you want me to do it?
Comment 5 Dominique d'Humieres 2015-11-19 07:51:20 UTC
> Do you want me to do it?

No feedback for more than two years. I am taking it.
Comment 6 Dominique d'Humieres 2016-04-06 15:46:24 UTC
Patch submitted at https://gcc.gnu.org/ml/fortran/2016-04/msg00024.html.
Comment 7 Dominique d'Humieres 2016-04-09 18:05:48 UTC
> Patch submitted at https://gcc.gnu.org/ml/fortran/2016-04/msg00024.html.

Flatly rejected at https://gcc.gnu.org/ml/fortran/2016-04/msg00025.html.

Per https://gcc.gnu.org/ml/fortran/2016-04/msg00030.html

> The above error is correct.  Adding any text referring
> to type-spec is wrong.

closing as INVALID.