<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Weird error messages in different versions of clang or in a newline"
href="https://bugs.llvm.org/show_bug.cgi?id=46339">46339</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Weird error messages in different versions of clang or in a newline
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>haoxintu@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>These cases make clang emitting different error messages. I think it's so weird
and I guess there might be somethings wrong with clang's parser. The only
difference between test1.cc and test2.cc is I make line3 and line4 together in
test2.cc and let them sperateted in test1.cc.
$cat test1.cc
bool var_bool;
void a() {
b <volatile >enum c
union { static_assert ( var_bool , "" )}
}
$cat test2.cc
bool var_bool;
void a() {
b <volatile >enum c union { static_assert ( var_bool , "" )}
}
$ clang++-trunk -w -c test1.cc
test1.cc:3:17: error: expected a type
b <volatile >enum c
^
test1.cc:3:24: error: expected ';' after enum
b <volatile >enum c
^
;
test1.cc:3:23: error: ISO C++ forbids forward references to 'enum' types
b <volatile >enum c
^
test1.cc:4:46: error: expected ';' after static_assert
union { static_assert ( var_bool , "" )}
^
;
test1.cc:4:31: error: static_assert expression is not an integral constant
expression
union { static_assert ( var_bool , "" )}
^~~~~~~~
test1.cc:4:31: note: read of non-const variable 'var_bool' is not allowed in a
constant expression
test1.cc:1:6: note: declared here
bool var_bool;
^
test1.cc:4:47: error: expected ';' after union
union { static_assert ( var_bool , "" )}
^
;
6 errors generated.
$ clang++-trunk -w -c test2.cc
test2.cc:3:17: error: expected a type
b <volatile >enum c union { static_assert ( var_bool , "" )}
^
test2.cc:3:23: error: ISO C++ forbids forward references to 'enum' types
b <volatile >enum c union { static_assert ( var_bool , "" )}
^
test2.cc:4:1: error: expected unqualified-id
}
^
3 errors generated.
While in clang-10 or lower versions, both test1.cc or test2.cc produce the same
results. Take clang-10 for example,
$clang++-10 -w -c test1.cc
test1.cc:3:17: error: expected a type
b <volatile >enum c
^
1 error generated.
$clang++-10 -w -c test2.cc
test1.cc:3:17: error: expected a type
b <volatile >enum c
^
1 error generated.
$clang++-trunk --version
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
e6aba43cda848f4a8cfa5ce9f174b77def10e9df)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-clang/llvm-project/build/bin
So, My concerns are
1. Why clang-trunk treats test1.cc and test2.cc differently just because of an
EOL?
2. The compiled results are inconsistent between clang-trunk and other clang
versions.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>