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