title: Unterminated argument list invoking macro: gcc vs. clang: error vs. no diagnostics
body: <p>Consider this code:</p>
  <pre><code>/* h2.h */
  #define F()
  F(
  
  /* t10.c */
  #include &quot;h2.h&quot;
  )
  int x; /* fix for &quot;warning: ISO C requires a translation unit to contain at least one declaration&quot; */
  </code></pre>
  <p>Invocation:</p>
  <pre><code>$ gcc t10.c -std=c11 -pedantic -Wall -Wextra -c
  In file included from t10.c:1:
  h2.h:2:3: error: unterminated argument list invoking macro &quot;F&quot;
      2 | F(
        |   ^
  t10.c:2:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘)’ token
      2 | )
        | ^
  
  $ clang t10.c -std=c11 -pedantic -Wall -Wextra -c
  &lt;nothing&gt;
  </code></pre>
  <p>Who is correct? Does this code trigger UB?</p>
  <hr />
  <p>UPD. Relevant quotes from C11:</p>
  <p>5.1.1.2 Translation phases, 1:</p>
  <blockquote>
  <p>A <code>#include</code> preprocessing directive causes the named header or source file to be processed from phase 1 through phase 4, recursively.</p>
  </blockquote>
  <p>6.10.3 Macro replacement, 10:</p>
  <blockquote>
  <p>The replaced sequence of preprocessing tokens is terminated by the matching <code>)</code> preprocessing token, skipping intervening matched pairs of left and right parenthesis preprocessing tokens.</p>
  </blockquote>
  <p>So, the source file <code>h2.h</code> processed from phase 1 through phase 4, and on phase 4 there is no matching <code>)</code> preprocessing token. This is violation of semantics of 6.10.3 Macro replacement. However, per 5.1.1.3 Diagnostics violation of semantics does not require producing of any diagnostics. I see it this way. Is that correct?</p>
  <hr />
  <p>UPD2. There is a constraint 6.10.3 Macro replacement, 4:</p>
  <blockquote>
  <p>There shall exist a <code>)</code> preprocessing token that terminates the invocation.</p>
  </blockquote>
  <p>So, it is a constraint violation. Diagnostics is required.</p>