OSDN Git Service

PR testsuite/35406
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / fmt_error_2.f90
1 ! { dg-do compile }
2 ! PR 33269: we used to not simplify format strings before checking if
3 ! they were valid, leading to a missed error.
4
5 IMPLICIT CHARACTER*5 (h-z)
6
7 CHARACTER*5 f
8 CHARACTER*5 bad, good
9 parameter(bad="a", good="(a)")
10
11 PRINT ('a'), "hello" ! { dg-error "Missing leading left parenthesis in format string" }
12 WRITE (*, ("a")) "error"  ! { dg-error "Missing leading left parenthesis in format string" }
13
14 PRINT 'a', "hello" ! { dg-error "Missing leading left parenthesis in format string" }
15 WRITE (*, "a") "error"  ! { dg-error "Missing leading left parenthesis in format string" }
16 WRITE (*, bad) "error"  ! { dg-error "Missing leading left parenthesis in format string" }
17
18 PRINT 'a' // ', a', "err", "or"   ! { dg-error "Missing leading left parenthesis in format string" }
19
20 PRINT '(' // 'a'  ! { dg-error "Unexpected end of format string in format string" }
21
22 ! the following are ok
23 PRINT "(2f5.3)", bar, foo
24 PRINT ' (a)', "hello"
25 WRITE (*, " ((a))") "hello"
26 print "(a" // ")", "all is fine"
27 print good, "great"
28
29 ! verify that we haven't broken non-constant expressions
30 f = "(f5.3)"
31 print f, 3.14159
32 print (f), 2.71813
33 print implicitly_typed, "something"
34 write (*, implicitly_typed_as_well) "something else"
35 END